diff --git a/CHANGELOG.md b/CHANGELOG.md index 483e0815..db26c18f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# [3.5.1] +* Bug fix for platform util. + # [3.5.0] * Removed redundant classes. diff --git a/lib/src/widgets/cursor.dart b/lib/src/widgets/cursor.dart index 3fb190a0..de2dbb5f 100644 --- a/lib/src/widgets/cursor.dart +++ b/lib/src/widgets/cursor.dart @@ -287,7 +287,15 @@ class CursorPainter { final caretHeight = editable!.getFullHeightForCaret(position); if (caretHeight != null) { - if (isKeyboardOS()) { + if (isAppleOS()) { + // Center the caret vertically along the text. + caretRect = Rect.fromLTWH( + caretRect.left, + caretRect.top + (caretHeight - caretRect.height) / 2, + caretRect.width, + caretRect.height, + ); + } else { // Override the height to take the full height of the glyph at the // TextPosition when not on iOS. iOS has special handling that // creates a taller caret. @@ -297,16 +305,6 @@ class CursorPainter { caretRect.width, caretHeight, ); - } else if (isAppleOS()) { - // Center the caret vertically along the text. - caretRect = Rect.fromLTWH( - caretRect.left, - caretRect.top + (caretHeight - caretRect.height) / 2, - caretRect.width, - caretRect.height, - ); - } else { - throw UnimplementedError(); } } diff --git a/lib/src/widgets/default_styles.dart b/lib/src/widgets/default_styles.dart index 15a5d4de..438ca7cf 100644 --- a/lib/src/widgets/default_styles.dart +++ b/lib/src/widgets/default_styles.dart @@ -195,10 +195,8 @@ class DefaultStyles { String fontFamily; if (isAppleOS(themeData.platform)) { fontFamily = 'Menlo'; - } else if (isKeyboardOS(themeData.platform)) { - fontFamily = 'Roboto Mono'; } else { - throw UnimplementedError(); + fontFamily = 'Roboto Mono'; } final inlineCodeStyle = TextStyle( diff --git a/lib/src/widgets/editor.dart b/lib/src/widgets/editor.dart index a6eab01d..f1ec50cf 100644 --- a/lib/src/widgets/editor.dart +++ b/lib/src/widgets/editor.dart @@ -398,14 +398,7 @@ class _QuillEditorState extends State Color selectionColor; Radius? cursorRadius; - if (isKeyboardOS(theme.platform)) { - textSelectionControls = materialTextSelectionControls; - paintCursorAboveText = false; - cursorOpacityAnimates = false; - cursorColor ??= selectionTheme.cursorColor ?? theme.colorScheme.primary; - selectionColor = selectionTheme.selectionColor ?? - theme.colorScheme.primary.withOpacity(0.40); - } else if (isAppleOS(theme.platform)) { + if (isAppleOS(theme.platform)) { final cupertinoTheme = CupertinoTheme.of(context); textSelectionControls = cupertinoTextSelectionControls; paintCursorAboveText = true; @@ -417,7 +410,12 @@ class _QuillEditorState extends State cursorOffset = Offset( iOSHorizontalOffset / MediaQuery.of(context).devicePixelRatio, 0); } else { - throw UnimplementedError(); + textSelectionControls = materialTextSelectionControls; + paintCursorAboveText = false; + cursorOpacityAnimates = false; + cursorColor ??= selectionTheme.cursorColor ?? theme.colorScheme.primary; + selectionColor = selectionTheme.selectionColor ?? + theme.colorScheme.primary.withOpacity(0.40); } final child = RawEditor( @@ -523,14 +521,12 @@ class _QuillEditorSelectionGestureDetectorBuilder from: details.globalPosition, cause: SelectionChangedCause.longPress, ); - } else if (isKeyboardOS(_platform)) { + } else { renderEditor!.selectWordsInRange( details.globalPosition - details.offsetFromOrigin, details.globalPosition, SelectionChangedCause.longPress, ); - } else { - throw UnimplementedError(); } } @@ -613,7 +609,7 @@ class _QuillEditorSelectionGestureDetectorBuilder ..onSelectionCompleted(); break; } - } else if (isKeyboardOS(_platform)) { + } else { renderEditor! ..selectPosition(cause: SelectionChangedCause.tap) ..onSelectionCompleted(); @@ -639,11 +635,9 @@ class _QuillEditorSelectionGestureDetectorBuilder from: details.globalPosition, cause: SelectionChangedCause.longPress, ); - } else if (isKeyboardOS(_platform)) { + } else { renderEditor!.selectWord(SelectionChangedCause.longPress); Feedback.forLongPress(_state.context); - } else { - throw UnimplementedError(); } } } diff --git a/lib/src/widgets/raw_editor.dart b/lib/src/widgets/raw_editor.dart index 9919b2ea..ef02fbc1 100644 --- a/lib/src/widgets/raw_editor.dart +++ b/lib/src/widgets/raw_editor.dart @@ -851,7 +851,7 @@ class RawEditorState extends EditorState bringIntoView(textEditingValue.selection.extent); hideToolbar(false); - if (isKeyboardOS() || Platform.isAndroid) { + if (!Platform.isIOS) { // Collapse the selection and hide the toolbar and handles. userUpdateTextEditingValue( TextEditingValue( diff --git a/lib/src/widgets/text_line.dart b/lib/src/widgets/text_line.dart index 73dc21f9..089db489 100644 --- a/lib/src/widgets/text_line.dart +++ b/lib/src/widgets/text_line.dart @@ -855,10 +855,8 @@ class RenderEditableTextLine extends RenderEditableBox { void _computeCaretPrototype() { if (isAppleOS()) { _caretPrototype = Rect.fromLTWH(0, 0, cursorWidth, cursorHeight + 2); - } else if (isKeyboardOS()) { - _caretPrototype = Rect.fromLTWH(0, 2, cursorWidth, cursorHeight - 4.0); } else { - throw UnimplementedError(); + _caretPrototype = Rect.fromLTWH(0, 2, cursorWidth, cursorHeight - 4.0); } } diff --git a/pubspec.yaml b/pubspec.yaml index 9c610270..0b768dce 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_quill description: A rich text editor supporting mobile and web (Demo App @ bulletjournal.us) -version: 3.5.0 +version: 3.5.1 #author: bulletjournal homepage: https://bulletjournal.us/home/index.html repository: https://github.com/singerdmx/flutter-quill