Skip to content

Commit

Permalink
Migrate to Flutter 3.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zmtzawqlp committed Feb 19, 2024
1 parent 0320f73 commit fdcb82b
Show file tree
Hide file tree
Showing 16 changed files with 563 additions and 448 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 14.0.0

* Migrate to Flutter 3.19.0
* Fix wrong postion of Magnifier

## 13.0.1

* Update readme about HarmonyOS
Expand Down
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ linter:
- always_declare_return_types
- always_put_control_body_on_new_line
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
- always_require_non_null_named_parameters
# - always_require_non_null_named_parameters
- always_specify_types
- annotate_overrides
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
Expand Down
2 changes: 1 addition & 1 deletion example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ linter:
- always_declare_return_types
- always_put_control_body_on_new_line
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
- always_require_non_null_named_parameters
# - always_require_non_null_named_parameters
- always_specify_types
- annotate_overrides
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
Expand Down
5 changes: 3 additions & 2 deletions example/lib/pages/simple/no_keyboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class TextFieldCaseState extends State<TextFieldCase>
mixin CustomKeyboardShowStateMixin<T extends StatefulWidget> on State<T> {
final TextInputFocusNode _focusNode = TextInputFocusNode();
final TextEditingController _controller = TextEditingController();
PersistentBottomSheetController<void>? _bottomSheetController;
PersistentBottomSheetController? _bottomSheetController;

final List<TextInputFormatter> _inputFormatters = <TextInputFormatter>[
// digit or decimal
Expand Down Expand Up @@ -129,12 +129,13 @@ mixin CustomKeyboardShowStateMixin<T extends StatefulWidget> on State<T> {
void _handleFocusChanged() {
if (_focusNode.hasFocus) {
// just demo, you can define your custom keyboard as you want
_bottomSheetController = showBottomSheet<void>(
_bottomSheetController = showBottomSheet(
context: FocusManager.instance.primaryFocus!.context!,
// set false, if don't want to drag to close custom keyboard
enableDrag: true,
builder: (BuildContext b) {
final MediaQueryData mediaQueryData = MediaQuery.of(b);

return Material(
//shadowColor: Colors.grey,
color: Colors.grey.withOpacity(0.3),
Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ publish_to: none
version: 1.0.0+1

environment:
sdk: '>=3.0.0 <4.0.0'
flutter: ">=3.16.0"
sdk: '>=3.3.0 <4.0.0'
flutter: ">=3.19.0"
dependencies:

# The following adds the Cupertino Icons font to your application.
Expand All @@ -25,7 +25,7 @@ dependencies:
cupertino_icons: ^1.0.4

ff_annotation_route_library: ^3.0.0
extended_text: ^12.0.0
extended_text: ^13.0.0
# extended_text:
# version: ^11.0.0-dev.1
# hosted: "https://pub.dev"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class ExtendedCupertinoSpellCheckSuggestionsToolbar extends StatelessWidget {
editableTextState
.bringIntoView(editableTextState.textEditingValue.selection.extent);
}
});
}, debugLabel: 'SpellCheckSuggestions.bringIntoView');
editableTextState.hideToolbar();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/extended/material/selectable_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class _ExtendedSelectableTextState extends _SelectableTextState {
assert(debugCheckHasDirectionality(context));
assert(
!(widget.style != null &&
widget.style!.inherit == false &&
!widget.style!.inherit &&
(widget.style!.fontSize == null ||
widget.style!.textBaseline == null)),
'inherit false style must supply fontSize and textBaseline',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class ExtendedSpellCheckSuggestionsToolbar extends StatelessWidget {
editableTextState
.bringIntoView(editableTextState.textEditingValue.selection.extent);
}
});
}, debugLabel: 'SpellCheckerSuggestionsToolbar.bringIntoView');
editableTextState.hideToolbar();
}

Expand Down
60 changes: 40 additions & 20 deletions lib/src/extended/widgets/editable_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ class ExtendedEditableTextState extends _EditableTextState {
compositeCallback: _compositeCallback,
enabled: _hasInputConnection,
child: TextFieldTapRegion(
onTapOutside: widget.onTapOutside ?? _defaultOnTapOutside,
onTapOutside:
_hasFocus ? widget.onTapOutside ?? _defaultOnTapOutside : null,
debugLabel: kReleaseMode ? null : 'EditableText',
child: MouseRegion(
cursor: widget.mouseCursor ?? SystemMouseCursors.text,
Expand Down Expand Up @@ -271,6 +272,15 @@ class ExtendedEditableTextState extends _EditableTextState {
return oldValue.text != newValue.text ||
oldValue.composing != newValue.composing;
},
undoStackModifier: (TextEditingValue value) {
// On Android we should discard the composing region when pushing
// a new entry to the undo stack. This prevents the TextInputPlugin
// from restarting the input on every undo/redo when the composing
// region is changed by the framework.
return defaultTargetPlatform == TargetPlatform.android
? value.copyWith(composing: TextRange.empty)
: value;
},
focusNode: widget.focusNode,
controller: widget.undoController,
child: Focus(
Expand Down Expand Up @@ -764,29 +774,41 @@ class ExtendedEditableTextState extends _EditableTextState {
// we cache the position.
_pointOffsetOrigin = point.offset;

// zmtzawqlp
final TextPosition currentTextPosition = supportSpecialText
? ExtendedTextLibraryUtils
.convertTextInputPostionToTextPainterPostion(
renderEditable.text!,
renderEditable.selection!.base,
)
: TextPosition(
offset: renderEditable.selection!.baseOffset,
affinity: renderEditable.selection!.affinity);

_startCaretRect =
renderEditable.getLocalRectForCaret(currentTextPosition);

_lastBoundedOffset = _startCaretRect!.center - _floatingCursorOffset;
final Offset startCaretCenter;
final TextPosition currentTextPosition;
final bool shouldResetOrigin;
// Only non-null when starting a floating cursor via long press.
if (point.startLocation != null) {
shouldResetOrigin = false;
(startCaretCenter, currentTextPosition) = point.startLocation!;
} else {
shouldResetOrigin = true;
// zmtzawqlp
currentTextPosition = supportSpecialText
? ExtendedTextLibraryUtils
.convertTextInputPostionToTextPainterPostion(
renderEditable.text!,
renderEditable.selection!.base,
)
: TextPosition(
offset: renderEditable.selection!.baseOffset,
affinity: renderEditable.selection!.affinity);
startCaretCenter =
renderEditable.getLocalRectForCaret(currentTextPosition).center;
}

_startCaretCenter = startCaretCenter;
_lastBoundedOffset =
renderEditable.calculateBoundedFloatingCursorOffset(
_startCaretCenter! - _floatingCursorOffset,
shouldResetOrigin: shouldResetOrigin);
_lastTextPosition = currentTextPosition;
renderEditable.setFloatingCursor(
point.state, _lastBoundedOffset!, _lastTextPosition!);
break;
case FloatingCursorDragState.Update:
final Offset centeredPoint = point.offset! - _pointOffsetOrigin!;
final Offset rawCursorOffset =
_startCaretRect!.center + centeredPoint - _floatingCursorOffset;
_startCaretCenter! + centeredPoint - _floatingCursorOffset;

_lastBoundedOffset = renderEditable
.calculateBoundedFloatingCursorOffset(rawCursorOffset);
Expand All @@ -801,7 +823,6 @@ class ExtendedEditableTextState extends _EditableTextState {

renderEditable.setFloatingCursor(
point.state, _lastBoundedOffset!, _lastTextPosition!);
break;
case FloatingCursorDragState.End:
// Resume cursor blinking.
_startCursorBlink();
Expand All @@ -813,7 +834,6 @@ class ExtendedEditableTextState extends _EditableTextState {
duration: _EditableTextState._floatingCursorResetTime,
curve: Curves.decelerate);
}
break;
}
}

Expand Down
6 changes: 5 additions & 1 deletion lib/src/extended/widgets/text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ExtendedTextField extends _TextField {
super.toolbarOptions,
super.showCursor,
super.autofocus = false,
super.statesController,
super.obscuringCharacter = '•',
super.obscureText = false,
super.autocorrect = true,
Expand All @@ -71,6 +72,7 @@ class ExtendedTextField extends _TextField {
super.cursorRadius,
super.cursorOpacityAnimates,
super.cursorColor,
super.cursorErrorColor,
super.selectionHeightStyle = ui.BoxHeightStyle.tight,
super.selectionWidthStyle = ui.BoxWidthStyle.tight,
super.keyboardAppearance,
Expand All @@ -79,6 +81,7 @@ class ExtendedTextField extends _TextField {
super.enableInteractiveSelection,
super.selectionControls,
super.onTap,
super.onTapAlwaysCalled = false,
super.onTapOutside,
super.mouseCursor,
super.buildCounter,
Expand All @@ -98,6 +101,7 @@ class ExtendedTextField extends _TextField {
// super.spellCheckConfiguration,
this.extendedSpellCheckConfiguration,
this.specialTextSpanBuilder,
super.magnifierConfiguration,
});

/// build your ccustom text span
Expand Down Expand Up @@ -554,7 +558,7 @@ class ExtendedTextFieldState extends _TextFieldState {
final MouseCursor effectiveMouseCursor =
MaterialStateProperty.resolveAs<MouseCursor>(
widget.mouseCursor ?? MaterialStateMouseCursor.textable,
_materialState,
_statesController.value,
);

final int? semanticsMaxValueLength;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/official/material/selectable_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ class _SelectableTextState extends State<_SelectableText>
assert(debugCheckHasDirectionality(context));
assert(
!(widget.style != null &&
widget.style!.inherit == false &&
!widget.style!.inherit &&
(widget.style!.fontSize == null ||
widget.style!.textBaseline == null)),
'inherit false style must supply fontSize and textBaseline',
Expand Down
Loading

0 comments on commit fdcb82b

Please sign in to comment.