mirror of
https://github.com/flutter/samples.git
synced 2025-11-13 10:59:04 +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:
@@ -273,7 +273,9 @@ class _PlaceMapState extends State<PlaceMap> {
|
||||
newConfiguration.selectedCategory) {
|
||||
// If the configuration change is only a category change, just update
|
||||
// the marker visibilities.
|
||||
await _showPlacesForSelectedCategory(newConfiguration.selectedCategory);
|
||||
await _showPlacesForSelectedCategory(
|
||||
newConfiguration.selectedCategory,
|
||||
);
|
||||
} else {
|
||||
// At this point, we know the places have been updated from the list
|
||||
// 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 {
|
||||
Provider.of<AppState>(context, listen: false).setSelectedCategory(category);
|
||||
Provider.of<AppState>(
|
||||
context,
|
||||
listen: false,
|
||||
).setSelectedCategory(category);
|
||||
await _showPlacesForSelectedCategory(category);
|
||||
}
|
||||
|
||||
@@ -361,7 +366,11 @@ class _PlaceMapState extends State<PlaceMap> {
|
||||
: null,
|
||||
),
|
||||
);
|
||||
_updateMarker(marker: marker, updatedMarker: updatedMarker, place: place);
|
||||
_updateMarker(
|
||||
marker: marker,
|
||||
updatedMarker: updatedMarker,
|
||||
place: place,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,7 @@ class PlatformImageFetcher {
|
||||
|
||||
/// Method responsible for providing the platform image.
|
||||
static Future<Uint8List> getImage() async {
|
||||
final reply =
|
||||
await _basicMessageChannel.send('getImage') as Uint8List?;
|
||||
final reply = await _basicMessageChannel.send('getImage') as Uint8List?;
|
||||
if (reply == null) {
|
||||
throw PlatformException(
|
||||
code: 'Error',
|
||||
|
||||
@@ -56,8 +56,7 @@ class PlatformAdaptingHomePage extends StatefulWidget {
|
||||
_PlatformAdaptingHomePageState();
|
||||
}
|
||||
|
||||
class _PlatformAdaptingHomePageState
|
||||
extends State<PlatformAdaptingHomePage> {
|
||||
class _PlatformAdaptingHomePageState extends State<PlatformAdaptingHomePage> {
|
||||
// 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
|
||||
// scaffolds, keeping a global key to it lets this app keep that tab's data as
|
||||
|
||||
@@ -55,9 +55,7 @@ class _NewsTabState extends State<NewsTab> {
|
||||
child: InkWell(
|
||||
// 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.
|
||||
onTap: defaultTargetPlatform == TargetPlatform.iOS
|
||||
? null
|
||||
: () {},
|
||||
onTap: defaultTargetPlatform == TargetPlatform.iOS ? null : () {},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Row(
|
||||
|
||||
@@ -39,8 +39,7 @@ String generateRandomHeadline() {
|
||||
2 => '$artist releases ${capitalizePair(wordPairIterator.first)}',
|
||||
3 => '$artist talks about his ${nouns[_random.nextInt(nouns.length)]}',
|
||||
4 => '$artist talks about her ${nouns[_random.nextInt(nouns.length)]}',
|
||||
5 =>
|
||||
'$artist talks about their ${nouns[_random.nextInt(nouns.length)]}',
|
||||
5 => '$artist talks about their ${nouns[_random.nextInt(nouns.length)]}',
|
||||
6 =>
|
||||
'$artist says their music is inspired by ${wordPairIterator.first.join(' ')}',
|
||||
7 =>
|
||||
|
||||
@@ -24,8 +24,7 @@ class CartModel extends ChangeNotifier {
|
||||
}
|
||||
|
||||
/// List of items in the cart.
|
||||
List<Item> get items =>
|
||||
_itemIds.map((id) => _catalog.getById(id)).toList();
|
||||
List<Item> get items => _itemIds.map((id) => _catalog.getById(id)).toList();
|
||||
|
||||
/// The current total price of all items.
|
||||
int get totalPrice =>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,11 @@ import 'package:testing_app/main.dart';
|
||||
|
||||
void main() {
|
||||
group('Testing App Performance Tests', () {
|
||||
final binding =
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
// The fullyLive frame policy simulates
|
||||
// the way Flutter responds to animations.
|
||||
binding.framePolicy =
|
||||
LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
||||
|
||||
testWidgets('Scrolling test', (tester) async {
|
||||
await tester.pumpWidget(const TestingApp());
|
||||
|
||||
@@ -41,8 +41,7 @@ class FavoriteItemTile extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor:
|
||||
Colors.primaries[itemNo % Colors.primaries.length],
|
||||
backgroundColor: Colors.primaries[itemNo % Colors.primaries.length],
|
||||
),
|
||||
title: Text('Item $itemNo', key: Key('favorites_text_$itemNo')),
|
||||
trailing: IconButton(
|
||||
|
||||
@@ -52,8 +52,7 @@ class ItemTile extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor:
|
||||
Colors.primaries[itemNo % Colors.primaries.length],
|
||||
backgroundColor: Colors.primaries[itemNo % Colors.primaries.length],
|
||||
),
|
||||
title: Text('Item $itemNo', key: Key('text_$itemNo')),
|
||||
trailing: IconButton(
|
||||
|
||||
@@ -52,9 +52,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Get the total number of items available.
|
||||
final totalItems = tester
|
||||
.widgetList(find.byIcon(Icons.close))
|
||||
.length;
|
||||
final totalItems = tester.widgetList(find.byIcon(Icons.close)).length;
|
||||
|
||||
// Remove one item.
|
||||
await tester.tap(find.byIcon(Icons.close).first);
|
||||
|
||||
Reference in New Issue
Block a user