mirror of
https://github.com/flutter/samples.git
synced 2025-11-14 03:19:06 +00:00
3.38 / 3.10 (#2742)
This PR makes samples pass CI when 3.10 is released. ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I have added sample code updates to the [changelog]. - [x] I updated/added relevant documentation (doc comments with `///`).
This commit is contained in:
@@ -135,8 +135,7 @@ class _BasicTextFieldState extends State<BasicTextField> {
|
||||
_textSelectionControls = cupertinoTextSelectionHandleControls;
|
||||
case TargetPlatform.macOS:
|
||||
// ignore: deprecated_member_use
|
||||
_textSelectionControls =
|
||||
cupertinoDesktopTextSelectionHandleControls;
|
||||
_textSelectionControls = cupertinoDesktopTextSelectionHandleControls;
|
||||
case TargetPlatform.android:
|
||||
case TargetPlatform.fuchsia:
|
||||
// ignore: deprecated_member_use
|
||||
@@ -153,8 +152,7 @@ class _BasicTextFieldState extends State<BasicTextField> {
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onPanStart: (dragStartDetails) => _onDragStart(dragStartDetails),
|
||||
onPanUpdate: (dragUpdateDetails) =>
|
||||
_onDragUpdate(dragUpdateDetails),
|
||||
onPanUpdate: (dragUpdateDetails) => _onDragUpdate(dragUpdateDetails),
|
||||
onSecondaryTapDown: (secondaryTapDownDetails) {
|
||||
_renderEditable.selectWordsInRange(
|
||||
from: secondaryTapDownDetails.globalPosition,
|
||||
|
||||
@@ -342,40 +342,40 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
||||
}
|
||||
|
||||
// These actions have yet to be implemented for this sample.
|
||||
static final Map<Type, Action<Intent>>
|
||||
_unsupportedActions = <Type, Action<Intent>>{
|
||||
DeleteToNextWordBoundaryIntent: DoNothingAction(consumesKey: false),
|
||||
DeleteToLineBreakIntent: DoNothingAction(consumesKey: false),
|
||||
ExtendSelectionToNextWordBoundaryIntent: DoNothingAction(
|
||||
consumesKey: false,
|
||||
),
|
||||
ExtendSelectionToNextParagraphBoundaryOrCaretLocationIntent:
|
||||
DoNothingAction(consumesKey: false),
|
||||
ExtendSelectionToLineBreakIntent: DoNothingAction(consumesKey: false),
|
||||
ExtendSelectionVerticallyToAdjacentLineIntent: DoNothingAction(
|
||||
consumesKey: false,
|
||||
),
|
||||
ExtendSelectionVerticallyToAdjacentPageIntent: DoNothingAction(
|
||||
consumesKey: false,
|
||||
),
|
||||
ExtendSelectionToNextParagraphBoundaryIntent: DoNothingAction(
|
||||
consumesKey: false,
|
||||
),
|
||||
ExtendSelectionToDocumentBoundaryIntent: DoNothingAction(
|
||||
consumesKey: false,
|
||||
),
|
||||
ExtendSelectionByPageIntent: DoNothingAction(consumesKey: false),
|
||||
ExpandSelectionToDocumentBoundaryIntent: DoNothingAction(
|
||||
consumesKey: false,
|
||||
),
|
||||
ExpandSelectionToLineBreakIntent: DoNothingAction(consumesKey: false),
|
||||
ScrollToDocumentBoundaryIntent: DoNothingAction(consumesKey: false),
|
||||
RedoTextIntent: DoNothingAction(consumesKey: false),
|
||||
ReplaceTextIntent: DoNothingAction(consumesKey: false),
|
||||
UndoTextIntent: DoNothingAction(consumesKey: false),
|
||||
UpdateSelectionIntent: DoNothingAction(consumesKey: false),
|
||||
TransposeCharactersIntent: DoNothingAction(consumesKey: false),
|
||||
};
|
||||
static final Map<Type, Action<Intent>> _unsupportedActions =
|
||||
<Type, Action<Intent>>{
|
||||
DeleteToNextWordBoundaryIntent: DoNothingAction(consumesKey: false),
|
||||
DeleteToLineBreakIntent: DoNothingAction(consumesKey: false),
|
||||
ExtendSelectionToNextWordBoundaryIntent: DoNothingAction(
|
||||
consumesKey: false,
|
||||
),
|
||||
ExtendSelectionToNextParagraphBoundaryOrCaretLocationIntent:
|
||||
DoNothingAction(consumesKey: false),
|
||||
ExtendSelectionToLineBreakIntent: DoNothingAction(consumesKey: false),
|
||||
ExtendSelectionVerticallyToAdjacentLineIntent: DoNothingAction(
|
||||
consumesKey: false,
|
||||
),
|
||||
ExtendSelectionVerticallyToAdjacentPageIntent: DoNothingAction(
|
||||
consumesKey: false,
|
||||
),
|
||||
ExtendSelectionToNextParagraphBoundaryIntent: DoNothingAction(
|
||||
consumesKey: false,
|
||||
),
|
||||
ExtendSelectionToDocumentBoundaryIntent: DoNothingAction(
|
||||
consumesKey: false,
|
||||
),
|
||||
ExtendSelectionByPageIntent: DoNothingAction(consumesKey: false),
|
||||
ExpandSelectionToDocumentBoundaryIntent: DoNothingAction(
|
||||
consumesKey: false,
|
||||
),
|
||||
ExpandSelectionToLineBreakIntent: DoNothingAction(consumesKey: false),
|
||||
ScrollToDocumentBoundaryIntent: DoNothingAction(consumesKey: false),
|
||||
RedoTextIntent: DoNothingAction(consumesKey: false),
|
||||
ReplaceTextIntent: DoNothingAction(consumesKey: false),
|
||||
UndoTextIntent: DoNothingAction(consumesKey: false),
|
||||
UpdateSelectionIntent: DoNothingAction(consumesKey: false),
|
||||
TransposeCharactersIntent: DoNothingAction(consumesKey: false),
|
||||
};
|
||||
|
||||
/// Keyboard text editing actions.
|
||||
// The Handling of the default text editing shortcuts with deltas
|
||||
@@ -582,9 +582,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
||||
|
||||
void _updateCaretRectIfNeeded() {
|
||||
final TextSelection? selection = renderEditable.selection;
|
||||
if (selection == null ||
|
||||
!selection.isValid ||
|
||||
!selection.isCollapsed) {
|
||||
if (selection == null || !selection.isValid || !selection.isCollapsed) {
|
||||
return;
|
||||
}
|
||||
final TextPosition currentTextPosition = TextPosition(
|
||||
@@ -982,9 +980,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
||||
final InlineSpan span = renderEditable.text!;
|
||||
final String prevText = span.toPlainText();
|
||||
final String currText = textEditingValue.text;
|
||||
if (prevText != currText ||
|
||||
!selection.isValid ||
|
||||
selection.isCollapsed) {
|
||||
if (prevText != currText || !selection.isValid || selection.isCollapsed) {
|
||||
return _GlyphHeights(
|
||||
start: renderEditable.preferredLineHeight,
|
||||
end: renderEditable.preferredLineHeight,
|
||||
@@ -994,13 +990,12 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
||||
final String selectedGraphemes = selection.textInside(currText);
|
||||
final int firstSelectedGraphemeExtent =
|
||||
selectedGraphemes.characters.first.length;
|
||||
final Rect? startCharacterRect = renderEditable
|
||||
.getRectForComposingRange(
|
||||
TextRange(
|
||||
start: selection.start,
|
||||
end: selection.start + firstSelectedGraphemeExtent,
|
||||
),
|
||||
);
|
||||
final Rect? startCharacterRect = renderEditable.getRectForComposingRange(
|
||||
TextRange(
|
||||
start: selection.start,
|
||||
end: selection.start + firstSelectedGraphemeExtent,
|
||||
),
|
||||
);
|
||||
final int lastSelectedGraphemeExtent =
|
||||
selectedGraphemes.characters.last.length;
|
||||
final Rect? endCharacterRect = renderEditable.getRectForComposingRange(
|
||||
@@ -1010,8 +1005,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
||||
),
|
||||
);
|
||||
return _GlyphHeights(
|
||||
start:
|
||||
startCharacterRect?.height ?? renderEditable.preferredLineHeight,
|
||||
start: startCharacterRect?.height ?? renderEditable.preferredLineHeight,
|
||||
end: endCharacterRect?.height ?? renderEditable.preferredLineHeight,
|
||||
);
|
||||
}
|
||||
@@ -1095,9 +1089,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
||||
}
|
||||
|
||||
return !textEditingValue.selection.isCollapsed &&
|
||||
textEditingValue.selection
|
||||
.textInside(textEditingValue.text)
|
||||
.trim() !=
|
||||
textEditingValue.selection.textInside(textEditingValue.text).trim() !=
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -1160,8 +1152,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
||||
startHandleLayerLink: _startHandleLayerLink,
|
||||
endHandleLayerLink: _endHandleLayerLink,
|
||||
inlineSpan: _buildTextSpan(),
|
||||
value:
|
||||
_value, // We pass value.selection to RenderEditable.
|
||||
value: _value, // We pass value.selection to RenderEditable.
|
||||
cursorColor: Colors.blue,
|
||||
backgroundCursorColor: Colors.grey[100],
|
||||
showCursor: ValueNotifier<bool>(_hasFocus),
|
||||
|
||||
@@ -131,16 +131,14 @@ class TextEditingInlineSpanReplacement {
|
||||
return copy(
|
||||
range: TextRange(start: range.start, end: range.end),
|
||||
);
|
||||
} else if (range.start >= insertionOffset &&
|
||||
range.end > insertionOffset) {
|
||||
} else if (range.start >= insertionOffset && range.end > insertionOffset) {
|
||||
return copy(
|
||||
range: TextRange(
|
||||
start: range.start + insertedLength,
|
||||
end: range.end + insertedLength,
|
||||
),
|
||||
);
|
||||
} else if (range.start < insertionOffset &&
|
||||
range.end > insertionOffset) {
|
||||
} else if (range.start < insertionOffset && range.end > insertionOffset) {
|
||||
return copy(
|
||||
range: TextRange(
|
||||
start: range.start,
|
||||
@@ -167,8 +165,7 @@ class TextEditingInlineSpanReplacement {
|
||||
: delta.replacementText.length - delta.textReplaced.length;
|
||||
|
||||
if (range.start >= replacedRange.start &&
|
||||
(range.start < replacedRange.end &&
|
||||
range.end > replacedRange.end)) {
|
||||
(range.start < replacedRange.end && range.end > replacedRange.end)) {
|
||||
if (replacementShortenedText) {
|
||||
return [
|
||||
copy(
|
||||
@@ -327,8 +324,7 @@ class TextEditingInlineSpanReplacement {
|
||||
} else if (range.end <= removalRange.start &&
|
||||
range.end < removalRange.end) {
|
||||
return [this];
|
||||
} else if (removalRange.isCollapsed &&
|
||||
range.end == removalRange.start) {
|
||||
} else if (removalRange.isCollapsed && range.end == removalRange.start) {
|
||||
return [this];
|
||||
}
|
||||
|
||||
@@ -728,8 +724,7 @@ class ReplacementTextEditingController extends TextEditingController {
|
||||
final List<TextEditingInlineSpanReplacement> toRemove = [];
|
||||
final List<TextEditingInlineSpanReplacement> toAdd = [];
|
||||
|
||||
for (final TextEditingInlineSpanReplacement replacement
|
||||
in replacements!) {
|
||||
for (final TextEditingInlineSpanReplacement replacement in replacements!) {
|
||||
if (replacement.range.end == selection.start) {
|
||||
TextStyle? replacementStyle =
|
||||
(replacement.generator('', const TextRange.collapsed(0))
|
||||
@@ -747,8 +742,7 @@ class ReplacementTextEditingController extends TextEditingController {
|
||||
replacements!.remove(replacementToRemove);
|
||||
}
|
||||
|
||||
for (final TextEditingInlineSpanReplacement
|
||||
replacementWithExpandDisabled
|
||||
for (final TextEditingInlineSpanReplacement replacementWithExpandDisabled
|
||||
in toAdd) {
|
||||
replacements!.add(replacementWithExpandDisabled);
|
||||
}
|
||||
@@ -763,8 +757,7 @@ class ReplacementTextEditingController extends TextEditingController {
|
||||
// should be enabled.
|
||||
final List<TextStyle> stylesAtSelection = <TextStyle>[];
|
||||
|
||||
for (final TextEditingInlineSpanReplacement replacement
|
||||
in replacements!) {
|
||||
for (final TextEditingInlineSpanReplacement replacement in replacements!) {
|
||||
if (selection.isCollapsed) {
|
||||
if (math.max(replacement.range.start, selection.start) <=
|
||||
math.min(replacement.range.end, selection.end)) {
|
||||
@@ -818,8 +811,8 @@ class ReplacementTextEditingController extends TextEditingController {
|
||||
math.min(replacement.range.end, removalRange.end)) &&
|
||||
replacementStyle != null) {
|
||||
if (replacementStyle == attribute!) {
|
||||
List<TextEditingInlineSpanReplacement>? newReplacements =
|
||||
replacement.removeRange(removalRange);
|
||||
List<TextEditingInlineSpanReplacement>? newReplacements = replacement
|
||||
.removeRange(removalRange);
|
||||
|
||||
if (newReplacements != null) {
|
||||
if (newReplacements.length == 1) {
|
||||
@@ -845,8 +838,7 @@ class ReplacementTextEditingController extends TextEditingController {
|
||||
replacements!.add(replacementToAdd);
|
||||
}
|
||||
|
||||
for (TextEditingInlineSpanReplacement replacementToRemove
|
||||
in toRemove) {
|
||||
for (TextEditingInlineSpanReplacement replacementToRemove in toRemove) {
|
||||
replacements!.remove(replacementToRemove);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user