1
0
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:
Eric Windmill
2025-11-12 11:46:47 -08:00
committed by GitHub
parent 744a2653c9
commit 3adcdc929a
13 changed files with 79 additions and 101 deletions

View File

@@ -273,7 +273,9 @@ class _PlaceMapState extends State<PlaceMap> {
newConfiguration.selectedCategory) { newConfiguration.selectedCategory) {
// If the configuration change is only a category change, just update // If the configuration change is only a category change, just update
// the marker visibilities. // the marker visibilities.
await _showPlacesForSelectedCategory(newConfiguration.selectedCategory); await _showPlacesForSelectedCategory(
newConfiguration.selectedCategory,
);
} else { } else {
// At this point, we know the places have been updated from the list // At this point, we know the places have been updated from the list
// view. We need to reconfigure the map to respect the updates. // view. We need to reconfigure the map to respect the updates.
@@ -343,7 +345,10 @@ class _PlaceMapState extends State<PlaceMap> {
} }
Future<void> _switchSelectedCategory(PlaceCategory category) async { Future<void> _switchSelectedCategory(PlaceCategory category) async {
Provider.of<AppState>(context, listen: false).setSelectedCategory(category); Provider.of<AppState>(
context,
listen: false,
).setSelectedCategory(category);
await _showPlacesForSelectedCategory(category); await _showPlacesForSelectedCategory(category);
} }
@@ -361,7 +366,11 @@ class _PlaceMapState extends State<PlaceMap> {
: null, : null,
), ),
); );
_updateMarker(marker: marker, updatedMarker: updatedMarker, place: place); _updateMarker(
marker: marker,
updatedMarker: updatedMarker,
place: place,
);
}); });
} }

View File

@@ -15,8 +15,7 @@ class PlatformImageFetcher {
/// Method responsible for providing the platform image. /// Method responsible for providing the platform image.
static Future<Uint8List> getImage() async { static Future<Uint8List> getImage() async {
final reply = final reply = await _basicMessageChannel.send('getImage') as Uint8List?;
await _basicMessageChannel.send('getImage') as Uint8List?;
if (reply == null) { if (reply == null) {
throw PlatformException( throw PlatformException(
code: 'Error', code: 'Error',

View File

@@ -56,8 +56,7 @@ class PlatformAdaptingHomePage extends StatefulWidget {
_PlatformAdaptingHomePageState(); _PlatformAdaptingHomePageState();
} }
class _PlatformAdaptingHomePageState class _PlatformAdaptingHomePageState extends State<PlatformAdaptingHomePage> {
extends State<PlatformAdaptingHomePage> {
// This app keeps a global key for the songs tab because it owns a bunch of // This app keeps a global key for the songs tab because it owns a bunch of
// data. Since changing platform re-parents those tabs into different // data. Since changing platform re-parents those tabs into different
// scaffolds, keeping a global key to it lets this app keep that tab's data as // scaffolds, keeping a global key to it lets this app keep that tab's data as

View File

@@ -55,9 +55,7 @@ class _NewsTabState extends State<NewsTab> {
child: InkWell( child: InkWell(
// Make it splash on Android. It would happen automatically if this // Make it splash on Android. It would happen automatically if this
// was a real card but this is just a demo. Skip the splash on iOS. // was a real card but this is just a demo. Skip the splash on iOS.
onTap: defaultTargetPlatform == TargetPlatform.iOS onTap: defaultTargetPlatform == TargetPlatform.iOS ? null : () {},
? null
: () {},
child: Padding( child: Padding(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Row( child: Row(

View File

@@ -39,8 +39,7 @@ String generateRandomHeadline() {
2 => '$artist releases ${capitalizePair(wordPairIterator.first)}', 2 => '$artist releases ${capitalizePair(wordPairIterator.first)}',
3 => '$artist talks about his ${nouns[_random.nextInt(nouns.length)]}', 3 => '$artist talks about his ${nouns[_random.nextInt(nouns.length)]}',
4 => '$artist talks about her ${nouns[_random.nextInt(nouns.length)]}', 4 => '$artist talks about her ${nouns[_random.nextInt(nouns.length)]}',
5 => 5 => '$artist talks about their ${nouns[_random.nextInt(nouns.length)]}',
'$artist talks about their ${nouns[_random.nextInt(nouns.length)]}',
6 => 6 =>
'$artist says their music is inspired by ${wordPairIterator.first.join(' ')}', '$artist says their music is inspired by ${wordPairIterator.first.join(' ')}',
7 => 7 =>

View File

@@ -24,8 +24,7 @@ class CartModel extends ChangeNotifier {
} }
/// List of items in the cart. /// List of items in the cart.
List<Item> get items => List<Item> get items => _itemIds.map((id) => _catalog.getById(id)).toList();
_itemIds.map((id) => _catalog.getById(id)).toList();
/// The current total price of all items. /// The current total price of all items.
int get totalPrice => int get totalPrice =>

View File

@@ -135,8 +135,7 @@ class _BasicTextFieldState extends State<BasicTextField> {
_textSelectionControls = cupertinoTextSelectionHandleControls; _textSelectionControls = cupertinoTextSelectionHandleControls;
case TargetPlatform.macOS: case TargetPlatform.macOS:
// ignore: deprecated_member_use // ignore: deprecated_member_use
_textSelectionControls = _textSelectionControls = cupertinoDesktopTextSelectionHandleControls;
cupertinoDesktopTextSelectionHandleControls;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
// ignore: deprecated_member_use // ignore: deprecated_member_use
@@ -153,8 +152,7 @@ class _BasicTextFieldState extends State<BasicTextField> {
child: GestureDetector( child: GestureDetector(
behavior: HitTestBehavior.translucent, behavior: HitTestBehavior.translucent,
onPanStart: (dragStartDetails) => _onDragStart(dragStartDetails), onPanStart: (dragStartDetails) => _onDragStart(dragStartDetails),
onPanUpdate: (dragUpdateDetails) => onPanUpdate: (dragUpdateDetails) => _onDragUpdate(dragUpdateDetails),
_onDragUpdate(dragUpdateDetails),
onSecondaryTapDown: (secondaryTapDownDetails) { onSecondaryTapDown: (secondaryTapDownDetails) {
_renderEditable.selectWordsInRange( _renderEditable.selectWordsInRange(
from: secondaryTapDownDetails.globalPosition, from: secondaryTapDownDetails.globalPosition,

View File

@@ -342,40 +342,40 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
} }
// These actions have yet to be implemented for this sample. // These actions have yet to be implemented for this sample.
static final Map<Type, Action<Intent>> static final Map<Type, Action<Intent>> _unsupportedActions =
_unsupportedActions = <Type, Action<Intent>>{ <Type, Action<Intent>>{
DeleteToNextWordBoundaryIntent: DoNothingAction(consumesKey: false), DeleteToNextWordBoundaryIntent: DoNothingAction(consumesKey: false),
DeleteToLineBreakIntent: DoNothingAction(consumesKey: false), DeleteToLineBreakIntent: DoNothingAction(consumesKey: false),
ExtendSelectionToNextWordBoundaryIntent: DoNothingAction( ExtendSelectionToNextWordBoundaryIntent: DoNothingAction(
consumesKey: false, consumesKey: false,
), ),
ExtendSelectionToNextParagraphBoundaryOrCaretLocationIntent: ExtendSelectionToNextParagraphBoundaryOrCaretLocationIntent:
DoNothingAction(consumesKey: false), DoNothingAction(consumesKey: false),
ExtendSelectionToLineBreakIntent: DoNothingAction(consumesKey: false), ExtendSelectionToLineBreakIntent: DoNothingAction(consumesKey: false),
ExtendSelectionVerticallyToAdjacentLineIntent: DoNothingAction( ExtendSelectionVerticallyToAdjacentLineIntent: DoNothingAction(
consumesKey: false, consumesKey: false,
), ),
ExtendSelectionVerticallyToAdjacentPageIntent: DoNothingAction( ExtendSelectionVerticallyToAdjacentPageIntent: DoNothingAction(
consumesKey: false, consumesKey: false,
), ),
ExtendSelectionToNextParagraphBoundaryIntent: DoNothingAction( ExtendSelectionToNextParagraphBoundaryIntent: DoNothingAction(
consumesKey: false, consumesKey: false,
), ),
ExtendSelectionToDocumentBoundaryIntent: DoNothingAction( ExtendSelectionToDocumentBoundaryIntent: DoNothingAction(
consumesKey: false, consumesKey: false,
), ),
ExtendSelectionByPageIntent: DoNothingAction(consumesKey: false), ExtendSelectionByPageIntent: DoNothingAction(consumesKey: false),
ExpandSelectionToDocumentBoundaryIntent: DoNothingAction( ExpandSelectionToDocumentBoundaryIntent: DoNothingAction(
consumesKey: false, consumesKey: false,
), ),
ExpandSelectionToLineBreakIntent: DoNothingAction(consumesKey: false), ExpandSelectionToLineBreakIntent: DoNothingAction(consumesKey: false),
ScrollToDocumentBoundaryIntent: DoNothingAction(consumesKey: false), ScrollToDocumentBoundaryIntent: DoNothingAction(consumesKey: false),
RedoTextIntent: DoNothingAction(consumesKey: false), RedoTextIntent: DoNothingAction(consumesKey: false),
ReplaceTextIntent: DoNothingAction(consumesKey: false), ReplaceTextIntent: DoNothingAction(consumesKey: false),
UndoTextIntent: DoNothingAction(consumesKey: false), UndoTextIntent: DoNothingAction(consumesKey: false),
UpdateSelectionIntent: DoNothingAction(consumesKey: false), UpdateSelectionIntent: DoNothingAction(consumesKey: false),
TransposeCharactersIntent: DoNothingAction(consumesKey: false), TransposeCharactersIntent: DoNothingAction(consumesKey: false),
}; };
/// Keyboard text editing actions. /// Keyboard text editing actions.
// The Handling of the default text editing shortcuts with deltas // The Handling of the default text editing shortcuts with deltas
@@ -582,9 +582,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
void _updateCaretRectIfNeeded() { void _updateCaretRectIfNeeded() {
final TextSelection? selection = renderEditable.selection; final TextSelection? selection = renderEditable.selection;
if (selection == null || if (selection == null || !selection.isValid || !selection.isCollapsed) {
!selection.isValid ||
!selection.isCollapsed) {
return; return;
} }
final TextPosition currentTextPosition = TextPosition( final TextPosition currentTextPosition = TextPosition(
@@ -982,9 +980,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
final InlineSpan span = renderEditable.text!; final InlineSpan span = renderEditable.text!;
final String prevText = span.toPlainText(); final String prevText = span.toPlainText();
final String currText = textEditingValue.text; final String currText = textEditingValue.text;
if (prevText != currText || if (prevText != currText || !selection.isValid || selection.isCollapsed) {
!selection.isValid ||
selection.isCollapsed) {
return _GlyphHeights( return _GlyphHeights(
start: renderEditable.preferredLineHeight, start: renderEditable.preferredLineHeight,
end: renderEditable.preferredLineHeight, end: renderEditable.preferredLineHeight,
@@ -994,13 +990,12 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
final String selectedGraphemes = selection.textInside(currText); final String selectedGraphemes = selection.textInside(currText);
final int firstSelectedGraphemeExtent = final int firstSelectedGraphemeExtent =
selectedGraphemes.characters.first.length; selectedGraphemes.characters.first.length;
final Rect? startCharacterRect = renderEditable final Rect? startCharacterRect = renderEditable.getRectForComposingRange(
.getRectForComposingRange( TextRange(
TextRange( start: selection.start,
start: selection.start, end: selection.start + firstSelectedGraphemeExtent,
end: selection.start + firstSelectedGraphemeExtent, ),
), );
);
final int lastSelectedGraphemeExtent = final int lastSelectedGraphemeExtent =
selectedGraphemes.characters.last.length; selectedGraphemes.characters.last.length;
final Rect? endCharacterRect = renderEditable.getRectForComposingRange( final Rect? endCharacterRect = renderEditable.getRectForComposingRange(
@@ -1010,8 +1005,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
), ),
); );
return _GlyphHeights( return _GlyphHeights(
start: start: startCharacterRect?.height ?? renderEditable.preferredLineHeight,
startCharacterRect?.height ?? renderEditable.preferredLineHeight,
end: endCharacterRect?.height ?? renderEditable.preferredLineHeight, end: endCharacterRect?.height ?? renderEditable.preferredLineHeight,
); );
} }
@@ -1095,9 +1089,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
} }
return !textEditingValue.selection.isCollapsed && return !textEditingValue.selection.isCollapsed &&
textEditingValue.selection textEditingValue.selection.textInside(textEditingValue.text).trim() !=
.textInside(textEditingValue.text)
.trim() !=
''; '';
} }
@@ -1160,8 +1152,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
startHandleLayerLink: _startHandleLayerLink, startHandleLayerLink: _startHandleLayerLink,
endHandleLayerLink: _endHandleLayerLink, endHandleLayerLink: _endHandleLayerLink,
inlineSpan: _buildTextSpan(), inlineSpan: _buildTextSpan(),
value: value: _value, // We pass value.selection to RenderEditable.
_value, // We pass value.selection to RenderEditable.
cursorColor: Colors.blue, cursorColor: Colors.blue,
backgroundCursorColor: Colors.grey[100], backgroundCursorColor: Colors.grey[100],
showCursor: ValueNotifier<bool>(_hasFocus), showCursor: ValueNotifier<bool>(_hasFocus),

View File

@@ -131,16 +131,14 @@ class TextEditingInlineSpanReplacement {
return copy( return copy(
range: TextRange(start: range.start, end: range.end), range: TextRange(start: range.start, end: range.end),
); );
} else if (range.start >= insertionOffset && } else if (range.start >= insertionOffset && range.end > insertionOffset) {
range.end > insertionOffset) {
return copy( return copy(
range: TextRange( range: TextRange(
start: range.start + insertedLength, start: range.start + insertedLength,
end: range.end + insertedLength, end: range.end + insertedLength,
), ),
); );
} else if (range.start < insertionOffset && } else if (range.start < insertionOffset && range.end > insertionOffset) {
range.end > insertionOffset) {
return copy( return copy(
range: TextRange( range: TextRange(
start: range.start, start: range.start,
@@ -167,8 +165,7 @@ class TextEditingInlineSpanReplacement {
: delta.replacementText.length - delta.textReplaced.length; : delta.replacementText.length - delta.textReplaced.length;
if (range.start >= replacedRange.start && if (range.start >= replacedRange.start &&
(range.start < replacedRange.end && (range.start < replacedRange.end && range.end > replacedRange.end)) {
range.end > replacedRange.end)) {
if (replacementShortenedText) { if (replacementShortenedText) {
return [ return [
copy( copy(
@@ -327,8 +324,7 @@ class TextEditingInlineSpanReplacement {
} else if (range.end <= removalRange.start && } else if (range.end <= removalRange.start &&
range.end < removalRange.end) { range.end < removalRange.end) {
return [this]; return [this];
} else if (removalRange.isCollapsed && } else if (removalRange.isCollapsed && range.end == removalRange.start) {
range.end == removalRange.start) {
return [this]; return [this];
} }
@@ -728,8 +724,7 @@ class ReplacementTextEditingController extends TextEditingController {
final List<TextEditingInlineSpanReplacement> toRemove = []; final List<TextEditingInlineSpanReplacement> toRemove = [];
final List<TextEditingInlineSpanReplacement> toAdd = []; final List<TextEditingInlineSpanReplacement> toAdd = [];
for (final TextEditingInlineSpanReplacement replacement for (final TextEditingInlineSpanReplacement replacement in replacements!) {
in replacements!) {
if (replacement.range.end == selection.start) { if (replacement.range.end == selection.start) {
TextStyle? replacementStyle = TextStyle? replacementStyle =
(replacement.generator('', const TextRange.collapsed(0)) (replacement.generator('', const TextRange.collapsed(0))
@@ -747,8 +742,7 @@ class ReplacementTextEditingController extends TextEditingController {
replacements!.remove(replacementToRemove); replacements!.remove(replacementToRemove);
} }
for (final TextEditingInlineSpanReplacement for (final TextEditingInlineSpanReplacement replacementWithExpandDisabled
replacementWithExpandDisabled
in toAdd) { in toAdd) {
replacements!.add(replacementWithExpandDisabled); replacements!.add(replacementWithExpandDisabled);
} }
@@ -763,8 +757,7 @@ class ReplacementTextEditingController extends TextEditingController {
// should be enabled. // should be enabled.
final List<TextStyle> stylesAtSelection = <TextStyle>[]; final List<TextStyle> stylesAtSelection = <TextStyle>[];
for (final TextEditingInlineSpanReplacement replacement for (final TextEditingInlineSpanReplacement replacement in replacements!) {
in replacements!) {
if (selection.isCollapsed) { if (selection.isCollapsed) {
if (math.max(replacement.range.start, selection.start) <= if (math.max(replacement.range.start, selection.start) <=
math.min(replacement.range.end, selection.end)) { math.min(replacement.range.end, selection.end)) {
@@ -818,8 +811,8 @@ class ReplacementTextEditingController extends TextEditingController {
math.min(replacement.range.end, removalRange.end)) && math.min(replacement.range.end, removalRange.end)) &&
replacementStyle != null) { replacementStyle != null) {
if (replacementStyle == attribute!) { if (replacementStyle == attribute!) {
List<TextEditingInlineSpanReplacement>? newReplacements = List<TextEditingInlineSpanReplacement>? newReplacements = replacement
replacement.removeRange(removalRange); .removeRange(removalRange);
if (newReplacements != null) { if (newReplacements != null) {
if (newReplacements.length == 1) { if (newReplacements.length == 1) {
@@ -845,8 +838,7 @@ class ReplacementTextEditingController extends TextEditingController {
replacements!.add(replacementToAdd); replacements!.add(replacementToAdd);
} }
for (TextEditingInlineSpanReplacement replacementToRemove for (TextEditingInlineSpanReplacement replacementToRemove in toRemove) {
in toRemove) {
replacements!.remove(replacementToRemove); replacements!.remove(replacementToRemove);
} }
} }

View File

@@ -9,13 +9,11 @@ import 'package:testing_app/main.dart';
void main() { void main() {
group('Testing App Performance Tests', () { group('Testing App Performance Tests', () {
final binding = final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
// The fullyLive frame policy simulates // The fullyLive frame policy simulates
// the way Flutter responds to animations. // the way Flutter responds to animations.
binding.framePolicy = binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
testWidgets('Scrolling test', (tester) async { testWidgets('Scrolling test', (tester) async {
await tester.pumpWidget(const TestingApp()); await tester.pumpWidget(const TestingApp());

View File

@@ -41,8 +41,7 @@ class FavoriteItemTile extends StatelessWidget {
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: ListTile( child: ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: backgroundColor: Colors.primaries[itemNo % Colors.primaries.length],
Colors.primaries[itemNo % Colors.primaries.length],
), ),
title: Text('Item $itemNo', key: Key('favorites_text_$itemNo')), title: Text('Item $itemNo', key: Key('favorites_text_$itemNo')),
trailing: IconButton( trailing: IconButton(

View File

@@ -52,8 +52,7 @@ class ItemTile extends StatelessWidget {
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: ListTile( child: ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: backgroundColor: Colors.primaries[itemNo % Colors.primaries.length],
Colors.primaries[itemNo % Colors.primaries.length],
), ),
title: Text('Item $itemNo', key: Key('text_$itemNo')), title: Text('Item $itemNo', key: Key('text_$itemNo')),
trailing: IconButton( trailing: IconButton(

View File

@@ -52,9 +52,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Get the total number of items available. // Get the total number of items available.
final totalItems = tester final totalItems = tester.widgetList(find.byIcon(Icons.close)).length;
.widgetList(find.byIcon(Icons.close))
.length;
// Remove one item. // Remove one item.
await tester.tap(find.byIcon(Icons.close).first); await tester.tap(find.byIcon(Icons.close).first);