diff --git a/examples/flutter_gallery/lib/demo/material/chip_demo.dart b/examples/flutter_gallery/lib/demo/material/chip_demo.dart index d531d4298a..fc1f497a72 100644 --- a/examples/flutter_gallery/lib/demo/material/chip_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/chip_demo.dart @@ -93,11 +93,11 @@ class _ChipsTile extends StatelessWidget { if (children.isNotEmpty) { cardChildren.add(Wrap( children: children.map((Widget chip) { - return Padding( - padding: const EdgeInsets.all(2.0), - child: chip, - ); - }).toList())); + return Padding( + padding: const EdgeInsets.all(2.0), + child: chip, + ); + }).toList())); } else { final TextStyle textStyle = Theme.of(context).textTheme.caption.copyWith(fontStyle: FontStyle.italic); cardChildren.add( diff --git a/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart b/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart index 8450a50de4..c758afa35f 100644 --- a/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart @@ -30,15 +30,15 @@ class OverscrollDemoState extends State { final Completer completer = Completer(); Timer(const Duration(seconds: 3), () { completer.complete(); }); return completer.future.then((_) { - _scaffoldKey.currentState?.showSnackBar(SnackBar( - content: const Text('Refresh complete'), - action: SnackBarAction( - label: 'RETRY', - onPressed: () { - _refreshIndicatorKey.currentState.show(); - }, - ), - )); + _scaffoldKey.currentState?.showSnackBar(SnackBar( + content: const Text('Refresh complete'), + action: SnackBarAction( + label: 'RETRY', + onPressed: () { + _refreshIndicatorKey.currentState.show(); + }, + ), + )); }); } diff --git a/examples/flutter_gallery/lib/demo/shrine/home.dart b/examples/flutter_gallery/lib/demo/shrine/home.dart index f213480fa3..c180c48bdf 100644 --- a/examples/flutter_gallery/lib/demo/shrine/home.dart +++ b/examples/flutter_gallery/lib/demo/shrine/home.dart @@ -31,7 +31,7 @@ class ProductPage extends StatelessWidget { return ScopedModelDescendant( builder: (BuildContext context, Widget child, AppStateModel model) { return AsymmetricView(products: model.getProducts()); - }); + }); } } diff --git a/examples/flutter_gallery/test/accessibility_test.dart b/examples/flutter_gallery/test/accessibility_test.dart index 1aa45cdfee..927e6a8263 100644 --- a/examples/flutter_gallery/test/accessibility_test.dart +++ b/examples/flutter_gallery/test/accessibility_test.dart @@ -104,70 +104,70 @@ void main() { }); testWidgets('leave_behind_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(const MaterialApp(home: LeaveBehindDemo())); await expectLater(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('list_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(const MaterialApp(home: ListDemo())); await expectLater(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('menu_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(const MaterialApp(home: MenuDemo())); await expectLater(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('modal_bottom_sheet_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(MaterialApp(home: ModalBottomSheetDemo())); await expectLater(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('overscroll_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(const MaterialApp(home: OverscrollDemo())); await expectLater(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('page_selector_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(MaterialApp(home: PageSelectorDemo())); await expectLater(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('persistent_bottom_sheet_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(MaterialApp(home: PersistentBottomSheetDemo())); await expectLater(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('progress_indicator_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(MaterialApp(home: ProgressIndicatorDemo())); await expectLater(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('reorderable_list_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(const MaterialApp(home: ReorderableListDemo())); await expectLater(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('scrollable_tabs_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(MaterialApp(home: ScrollableTabsDemo())); await expectLater(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); @@ -337,70 +337,70 @@ void main() { }); testWidgets('leave_behind_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(const MaterialApp(home: LeaveBehindDemo())); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); handle.dispose(); }); testWidgets('list_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(const MaterialApp(home: ListDemo())); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); handle.dispose(); }); testWidgets('menu_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(const MaterialApp(home: MenuDemo())); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); handle.dispose(); }); testWidgets('modal_bottom_sheet_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(MaterialApp(home: ModalBottomSheetDemo())); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); handle.dispose(); }); testWidgets('overscroll_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(const MaterialApp(home: OverscrollDemo())); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); handle.dispose(); }); testWidgets('page_selector_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(MaterialApp(home: PageSelectorDemo())); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); handle.dispose(); }); testWidgets('persistent_bottom_sheet_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(MaterialApp(home: PersistentBottomSheetDemo())); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); handle.dispose(); }); testWidgets('progress_indicator_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(MaterialApp(home: ProgressIndicatorDemo())); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); handle.dispose(); }); testWidgets('reorderable_list_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(const MaterialApp(home: ReorderableListDemo())); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); handle.dispose(); }); testWidgets('scrollable_tabs_demo', (WidgetTester tester) async { - final SemanticsHandle handle = tester.ensureSemantics(); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(MaterialApp(home: ScrollableTabsDemo())); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); handle.dispose(); diff --git a/examples/flutter_gallery/test/demo/material/expansion_panels_demo_test.dart b/examples/flutter_gallery/test/demo/material/expansion_panels_demo_test.dart index 29c940bdd3..ecefaaae0c 100644 --- a/examples/flutter_gallery/test/demo/material/expansion_panels_demo_test.dart +++ b/examples/flutter_gallery/test/demo/material/expansion_panels_demo_test.dart @@ -7,8 +7,7 @@ import 'package:flutter_gallery/demo/material/expansion_panels_demo.dart'; import 'package:flutter_test/flutter_test.dart'; Future main() async { - testWidgets('Expansion panel demo: radio tile selection changes on tap', - (WidgetTester tester) async { + testWidgets('Expansion panel demo: radio tile selection changes on tap', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp(home: ExpansionPanelsDemo())); expect(_expandIcons, findsNWidgets(3)); diff --git a/examples/platform_channel_swift/test_driver/button_tap_test.dart b/examples/platform_channel_swift/test_driver/button_tap_test.dart index 1fc9ed740d..974975990a 100644 --- a/examples/platform_channel_swift/test_driver/button_tap_test.dart +++ b/examples/platform_channel_swift/test_driver/button_tap_test.dart @@ -19,18 +19,18 @@ void main() { }); test('tap on the button, verify result', () async { - final SerializableFinder batteryLevelLabel = find.byValueKey('Battery level label'); - expect(batteryLevelLabel, isNotNull); + final SerializableFinder batteryLevelLabel = find.byValueKey('Battery level label'); + expect(batteryLevelLabel, isNotNull); - final SerializableFinder button = find.text('Get Battery Level'); - await driver.waitFor(button); - await driver.tap(button); + final SerializableFinder button = find.text('Get Battery Level'); + await driver.waitFor(button); + await driver.tap(button); - String batteryLevel; - while (batteryLevel == null || batteryLevel.isEmpty) { - batteryLevel = await driver.getText(batteryLevelLabel); - } - expect(batteryLevel, isNotEmpty); + String batteryLevel; + while (batteryLevel == null || batteryLevel.isEmpty) { + batteryLevel = await driver.getText(batteryLevelLabel); + } + expect(batteryLevel, isNotEmpty); }); }); } diff --git a/examples/stocks/lib/stock_settings.dart b/examples/stocks/lib/stock_settings.dart index 68d77d288c..b01789bad4 100644 --- a/examples/stocks/lib/stock_settings.dart +++ b/examples/stocks/lib/stock_settings.dart @@ -67,7 +67,7 @@ class StockSettingsState extends State { case StockMode.pessimistic: showDialog( context: context, - builder: (BuildContext context) { + builder: (BuildContext context) { return AlertDialog( title: const Text('Change mode?'), content: const Text('Optimistic mode means everything is awesome. Are you sure you can handle that?'), diff --git a/packages/flutter/lib/src/cupertino/picker.dart b/packages/flutter/lib/src/cupertino/picker.dart index 0426341e41..bd3e855251 100644 --- a/packages/flutter/lib/src/cupertino/picker.dart +++ b/packages/flutter/lib/src/cupertino/picker.dart @@ -415,7 +415,7 @@ class _RenderCupertinoPickerSemantics extends RenderProxyBox { if (_currentIndex == 0) return; controller.jumpToItem(_currentIndex - 1); - } + } void _handleScrollUpdate() { if (controller.selectedItem == _currentIndex) diff --git a/packages/flutter/lib/src/cupertino/segmented_control.dart b/packages/flutter/lib/src/cupertino/segmented_control.dart index 0438d44258..8873292983 100644 --- a/packages/flutter/lib/src/cupertino/segmented_control.dart +++ b/packages/flutter/lib/src/cupertino/segmented_control.dart @@ -204,10 +204,10 @@ class _SegmentedControlState extends State> duration: _kFadeDuration, vsync: this, )..addListener(() { - setState(() { - // State of background/text colors has changed - }); + setState(() { + // State of background/text colors has changed }); + }); } bool _updateColors() { diff --git a/packages/flutter/lib/src/material/reorderable_list.dart b/packages/flutter/lib/src/material/reorderable_list.dart index 7127695858..dcc4a94fa7 100644 --- a/packages/flutter/lib/src/material/reorderable_list.dart +++ b/packages/flutter/lib/src/material/reorderable_list.dart @@ -536,52 +536,52 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T assert(debugCheckHasMaterialLocalizations(context)); // We use the layout builder to constrain the cross-axis size of dragging child widgets. return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { - final List wrappedChildren = []; - if (widget.header != null) { - wrappedChildren.add(widget.header); - } - for (int i = 0; i < widget.children.length; i += 1) { - wrappedChildren.add(_wrap(widget.children[i], i, constraints)); - } - const Key endWidgetKey = Key('DraggableList - End Widget'); - Widget finalDropArea; - switch (widget.scrollDirection) { - case Axis.horizontal: - finalDropArea = SizedBox( - key: endWidgetKey, - width: _defaultDropAreaExtent, - height: constraints.maxHeight, - ); - break; - case Axis.vertical: - default: - finalDropArea = SizedBox( - key: endWidgetKey, - height: _defaultDropAreaExtent, - width: constraints.maxWidth, - ); - break; - } - if (widget.reverse) { - wrappedChildren.insert(0, _wrap( - finalDropArea, - widget.children.length, - constraints), + final List wrappedChildren = []; + if (widget.header != null) { + wrappedChildren.add(widget.header); + } + for (int i = 0; i < widget.children.length; i += 1) { + wrappedChildren.add(_wrap(widget.children[i], i, constraints)); + } + const Key endWidgetKey = Key('DraggableList - End Widget'); + Widget finalDropArea; + switch (widget.scrollDirection) { + case Axis.horizontal: + finalDropArea = SizedBox( + key: endWidgetKey, + width: _defaultDropAreaExtent, + height: constraints.maxHeight, ); - } else { - wrappedChildren.add(_wrap( - finalDropArea, - widget.children.length, - constraints), + break; + case Axis.vertical: + default: + finalDropArea = SizedBox( + key: endWidgetKey, + height: _defaultDropAreaExtent, + width: constraints.maxWidth, ); - } - return SingleChildScrollView( - scrollDirection: widget.scrollDirection, - child: _buildContainerForScrollDirection(children: wrappedChildren), - padding: widget.padding, - controller: _scrollController, - reverse: widget.reverse, + break; + } + if (widget.reverse) { + wrappedChildren.insert(0, _wrap( + finalDropArea, + widget.children.length, + constraints), ); + } else { + wrappedChildren.add(_wrap( + finalDropArea, + widget.children.length, + constraints), + ); + } + return SingleChildScrollView( + scrollDirection: widget.scrollDirection, + child: _buildContainerForScrollDirection(children: wrappedChildren), + padding: widget.padding, + controller: _scrollController, + reverse: widget.reverse, + ); }); } } diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index 58eb19d0e4..064cb6b1cd 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -879,7 +879,7 @@ class RenderAnimatedOpacity extends RenderProxyBox { super.attach(owner); _opacity.addListener(_updateOpacity); _updateOpacity(); // in case it changed while we weren't listening - } + } @override void detach() { @@ -1181,7 +1181,7 @@ abstract class _RenderCustomClip extends RenderProxyBox { void attach(PipelineOwner owner) { super.attach(owner); _clipper?._reclip?.addListener(_markNeedsClip); - } + } @override void detach() { diff --git a/packages/flutter/lib/src/widgets/drag_target.dart b/packages/flutter/lib/src/widgets/drag_target.dart index fa8f4ad69a..1e5a1f876a 100644 --- a/packages/flutter/lib/src/widgets/drag_target.dart +++ b/packages/flutter/lib/src/widgets/drag_target.dart @@ -650,7 +650,8 @@ class _DragAvatar extends Drag { _leaveAllEntered(); // Enter new targets. - final _DragTargetState newTarget = targets.firstWhere((_DragTargetState target) { + final _DragTargetState newTarget = targets.firstWhere( + (_DragTargetState target) { _enteredTargets.add(target); return target.didEnter(this); }, diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 131bac7035..d23568fa8f 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -2250,7 +2250,7 @@ class BuildOwner { context._debugSetAllowIgnoredCallsToMarkNeedsBuild(true); debugPreviousBuildTarget = _debugCurrentBuildTarget; _debugCurrentBuildTarget = context; - return true; + return true; }()); _dirtyElementsNeedsResorting = false; try { diff --git a/packages/flutter/lib/src/widgets/gesture_detector.dart b/packages/flutter/lib/src/widgets/gesture_detector.dart index 861d90c851..f0da9d4054 100644 --- a/packages/flutter/lib/src/widgets/gesture_detector.dart +++ b/packages/flutter/lib/src/widgets/gesture_detector.dart @@ -555,13 +555,13 @@ class GestureDetector extends StatelessWidget { onForcePressUpdate != null || onForcePressEnd != null) { gestures[ForcePressGestureRecognizer] = GestureRecognizerFactoryWithHandlers( - () => ForcePressGestureRecognizer(debugOwner: this), - (ForcePressGestureRecognizer instance) { - instance - ..onStart = onForcePressStart - ..onPeak = onForcePressPeak - ..onUpdate = onForcePressUpdate - ..onEnd = onForcePressEnd; + () => ForcePressGestureRecognizer(debugOwner: this), + (ForcePressGestureRecognizer instance) { + instance + ..onStart = onForcePressStart + ..onPeak = onForcePressPeak + ..onUpdate = onForcePressUpdate + ..onEnd = onForcePressEnd; }, ); } diff --git a/packages/flutter/lib/src/widgets/overlay.dart b/packages/flutter/lib/src/widgets/overlay.dart index aab056f33f..70a1212754 100644 --- a/packages/flutter/lib/src/widgets/overlay.dart +++ b/packages/flutter/lib/src/widgets/overlay.dart @@ -592,7 +592,7 @@ class _RenderTheatre extends RenderBox ); } return children; - } + } @override void visitChildrenForSemantics(RenderObjectVisitor visitor) { diff --git a/packages/flutter/lib/src/widgets/text_selection.dart b/packages/flutter/lib/src/widgets/text_selection.dart index 9ae01cb6f5..081d3fda0d 100644 --- a/packages/flutter/lib/src/widgets/text_selection.dart +++ b/packages/flutter/lib/src/widgets/text_selection.dart @@ -865,8 +865,8 @@ class _TextSelectionGestureDetectorState extends State gestures = {}; gestures[TapGestureRecognizer] = GestureRecognizerFactoryWithHandlers( - () => TapGestureRecognizer(debugOwner: this), - (TapGestureRecognizer instance) { + () => TapGestureRecognizer(debugOwner: this), + (TapGestureRecognizer instance) { instance ..onTapDown = _handleTapDown ..onTapUp = _handleTapUp @@ -878,8 +878,8 @@ class _TextSelectionGestureDetectorState extends State( - () => LongPressGestureRecognizer(debugOwner: this, kind: PointerDeviceKind.touch), - (LongPressGestureRecognizer instance) { + () => LongPressGestureRecognizer(debugOwner: this, kind: PointerDeviceKind.touch), + (LongPressGestureRecognizer instance) { instance ..onLongPressStart = _handleLongPressStart ..onLongPressMoveUpdate = _handleLongPressMoveUpdate @@ -894,8 +894,8 @@ class _TextSelectionGestureDetectorState extends State( - () => HorizontalDragGestureRecognizer(debugOwner: this, kind: PointerDeviceKind.mouse), - (HorizontalDragGestureRecognizer instance) { + () => HorizontalDragGestureRecognizer(debugOwner: this, kind: PointerDeviceKind.mouse), + (HorizontalDragGestureRecognizer instance) { instance // Text selection should start from the position of the first pointer // down event. @@ -909,8 +909,8 @@ class _TextSelectionGestureDetectorState extends State( - () => ForcePressGestureRecognizer(debugOwner: this), - (ForcePressGestureRecognizer instance) { + () => ForcePressGestureRecognizer(debugOwner: this), + (ForcePressGestureRecognizer instance) { instance ..onStart = widget.onForcePressStart != null ? _forcePressStarted : null ..onEnd = widget.onForcePressEnd != null ? _forcePressEnded : null; diff --git a/packages/flutter/test/animation/animations_test.dart b/packages/flutter/test/animation/animations_test.dart index 2175587d5a..6dfd76a37f 100644 --- a/packages/flutter/test/animation/animations_test.dart +++ b/packages/flutter/test/animation/animations_test.dart @@ -105,9 +105,12 @@ void main() { nextTrain.value = 0.75; bool didSwitchTrains = false; final TrainHoppingAnimation animation = TrainHoppingAnimation( - currentTrain, nextTrain, onSwitchedTrain: () { + currentTrain, + nextTrain, + onSwitchedTrain: () { didSwitchTrains = true; - }); + }, + ); expect(didSwitchTrains, isFalse); expect(animation.value, 0.5); expect(animation, hasOneLineDescription); diff --git a/packages/flutter/test/cupertino/action_sheet_test.dart b/packages/flutter/test/cupertino/action_sheet_test.dart index 2a0cb58bca..1e8fb2af5b 100644 --- a/packages/flutter/test/cupertino/action_sheet_test.dart +++ b/packages/flutter/test/cupertino/action_sheet_test.dart @@ -10,8 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; import '../widgets/semantics_tester.dart'; void main() { - testWidgets('Verify that a tap on modal barrier dismisses an action sheet', - (WidgetTester tester) async { + testWidgets('Verify that a tap on modal barrier dismisses an action sheet', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( const CupertinoActionSheet( @@ -30,8 +29,7 @@ void main() { expect(find.text('Action Sheet'), findsNothing); }); - testWidgets('Verify that a tap on title section (not buttons) does not dismiss an action sheet', - (WidgetTester tester) async { + testWidgets('Verify that a tap on title section (not buttons) does not dismiss an action sheet', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( const CupertinoActionSheet( @@ -82,8 +80,7 @@ void main() { expect(widget.style.fontWeight, equals(FontWeight.w600)); }); - testWidgets('Action sheet text styles are correct when both title and message are included', - (WidgetTester tester) async { + testWidgets('Action sheet text styles are correct when both title and message are included', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( const CupertinoActionSheet( @@ -105,8 +102,7 @@ void main() { expect(messageStyle.style.fontWeight, FontWeight.w400); }); - testWidgets('Action sheet text styles are correct when title but no message is included', - (WidgetTester tester) async { + testWidgets('Action sheet text styles are correct when title but no message is included', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( const CupertinoActionSheet( @@ -124,8 +120,7 @@ void main() { expect(titleStyle.style.fontWeight, FontWeight.w400); }); - testWidgets('Action sheet text styles are correct when message but no title is included', - (WidgetTester tester) async { + testWidgets('Action sheet text styles are correct when message but no title is included', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( const CupertinoActionSheet( @@ -364,8 +359,7 @@ void main() { expect(find.text('One'), findsNothing); }); - testWidgets('Action sheet width is correct when given infinite horizontal space', - (WidgetTester tester) async { + testWidgets('Action sheet width is correct when given infinite horizontal space', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( Row( @@ -393,8 +387,7 @@ void main() { expect(tester.getSize(find.byType(CupertinoActionSheet)).width, 600.0); }); - testWidgets('Action sheet height is correct when given infinite vertical space', - (WidgetTester tester) async { + testWidgets('Action sheet height is correct when given infinite vertical space', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( Column( diff --git a/packages/flutter/test/cupertino/bottom_tab_bar_test.dart b/packages/flutter/test/cupertino/bottom_tab_bar_test.dart index aa99959efc..2f88b3339d 100644 --- a/packages/flutter/test/cupertino/bottom_tab_bar_test.dart +++ b/packages/flutter/test/cupertino/bottom_tab_bar_test.dart @@ -246,22 +246,22 @@ void main() { testWidgets('Tap callback', (WidgetTester tester) async { int callbackTab; - await pumpWidgetWithBoilerplate(tester, MediaQuery( - data: const MediaQueryData(), - child: CupertinoTabBar( - items: const [ - BottomNavigationBarItem( - icon: ImageIcon(TestImageProvider(24, 24)), - title: Text('Tab 1'), - ), - BottomNavigationBarItem( - icon: ImageIcon(TestImageProvider(24, 24)), - title: Text('Tab 2'), - ), - ], - currentIndex: 1, - onTap: (int tab) { callbackTab = tab; }, - ), + await pumpWidgetWithBoilerplate(tester, MediaQuery( + data: const MediaQueryData(), + child: CupertinoTabBar( + items: const [ + BottomNavigationBarItem( + icon: ImageIcon(TestImageProvider(24, 24)), + title: Text('Tab 1'), + ), + BottomNavigationBarItem( + icon: ImageIcon(TestImageProvider(24, 24)), + title: Text('Tab 2'), + ), + ], + currentIndex: 1, + onTap: (int tab) { callbackTab = tab; }, + ), )); await tester.tap(find.text('Tab 1')); @@ -338,8 +338,7 @@ void main() { expect(itemsTapped, [1]); }); - testWidgets('Hide border hides the top border of the tabBar', - (WidgetTester tester) async { + testWidgets('Hide border hides the top border of the tabBar', (WidgetTester tester) async { await pumpWidgetWithBoilerplate( tester, MediaQuery( diff --git a/packages/flutter/test/cupertino/nav_bar_test.dart b/packages/flutter/test/cupertino/nav_bar_test.dart index b59da698f7..365f132614 100644 --- a/packages/flutter/test/cupertino/nav_bar_test.dart +++ b/packages/flutter/test/cupertino/nav_bar_test.dart @@ -645,9 +645,7 @@ void main() { expect(decoration.border, isNull); }); - testWidgets( - 'Border is displayed by default in sliver nav bar', - (WidgetTester tester) async { + testWidgets('Border is displayed by default in sliver nav bar', (WidgetTester tester) async { await tester.pumpWidget( const CupertinoApp( home: CupertinoPageScaffold( @@ -675,9 +673,7 @@ void main() { expect(bottom, isNotNull); }); - testWidgets( - 'Border is not displayed when null in sliver nav bar', - (WidgetTester tester) async { + testWidgets('Border is not displayed when null in sliver nav bar', (WidgetTester tester) async { await tester.pumpWidget( const CupertinoApp( home: CupertinoPageScaffold( @@ -749,9 +745,7 @@ void main() { semantics.dispose(); }); - testWidgets( - 'Border can be overridden in sliver nav bar', - (WidgetTester tester) async { + testWidgets('Border can be overridden in sliver nav bar', (WidgetTester tester) async { await tester.pumpWidget( const CupertinoApp( home: CupertinoPageScaffold( diff --git a/packages/flutter/test/cupertino/nav_bar_transition_test.dart b/packages/flutter/test/cupertino/nav_bar_transition_test.dart index 8c23ccc2ae..4b142d7484 100644 --- a/packages/flutter/test/cupertino/nav_bar_transition_test.dart +++ b/packages/flutter/test/cupertino/nav_bar_transition_test.dart @@ -124,8 +124,7 @@ void checkOpacity(WidgetTester tester, Finder finder, double opacity) { } void main() { - testWidgets('Bottom middle moves between middle and back label', - (WidgetTester tester) async { + testWidgets('Bottom middle moves between middle and back label', (WidgetTester tester) async { await startTransitionBetween(tester, fromTitle: 'Page 1'); // Be mid-transition. @@ -147,8 +146,7 @@ void main() { ); }); - testWidgets('Bottom middle moves between middle and back label RTL', - (WidgetTester tester) async { + testWidgets('Bottom middle moves between middle and back label RTL', (WidgetTester tester) async { await startTransitionBetween( tester, fromTitle: 'Page 1', @@ -169,8 +167,7 @@ void main() { ); }); - testWidgets('Bottom middle and top back label transitions their font', - (WidgetTester tester) async { + testWidgets('Bottom middle and top back label transitions their font', (WidgetTester tester) async { await startTransitionBetween(tester, fromTitle: 'Page 1'); // Be mid-transition. @@ -216,57 +213,55 @@ void main() { tester, flying(tester, find.text('Page 1')).last, 0.7630139589309692); }); - testWidgets('Font transitions respect themes', - (WidgetTester tester) async { - await startTransitionBetween( - tester, - fromTitle: 'Page 1', - theme: const CupertinoThemeData(brightness: Brightness.dark), - ); + testWidgets('Font transitions respect themes', (WidgetTester tester) async { + await startTransitionBetween( + tester, + fromTitle: 'Page 1', + theme: const CupertinoThemeData(brightness: Brightness.dark), + ); - // Be mid-transition. - await tester.pump(const Duration(milliseconds: 50)); + // Be mid-transition. + await tester.pump(const Duration(milliseconds: 50)); - // The transition's stack is ordered. The bottom middle is inserted first. - final RenderParagraph bottomMiddle = - tester.renderObject(flying(tester, find.text('Page 1')).first); - expect(bottomMiddle.text.style.color, const Color(0xfffffaf4)); - expect(bottomMiddle.text.style.fontWeight, FontWeight.w600); - expect(bottomMiddle.text.style.fontFamily, '.SF Pro Text'); - expect(bottomMiddle.text.style.letterSpacing, -0.41); + // The transition's stack is ordered. The bottom middle is inserted first. + final RenderParagraph bottomMiddle = + tester.renderObject(flying(tester, find.text('Page 1')).first); + expect(bottomMiddle.text.style.color, const Color(0xfffffaf4)); + expect(bottomMiddle.text.style.fontWeight, FontWeight.w600); + expect(bottomMiddle.text.style.fontFamily, '.SF Pro Text'); + expect(bottomMiddle.text.style.letterSpacing, -0.41); - checkOpacity(tester, flying(tester, find.text('Page 1')).first, 0.9004602432250977); + checkOpacity(tester, flying(tester, find.text('Page 1')).first, 0.9004602432250977); - // The top back label is styled exactly the same way. But the opacity tweens - // are flipped. - final RenderParagraph topBackLabel = - tester.renderObject(flying(tester, find.text('Page 1')).last); - expect(topBackLabel.text.style.color, const Color(0xfffffaf4)); - expect(topBackLabel.text.style.fontWeight, FontWeight.w600); - expect(topBackLabel.text.style.fontFamily, '.SF Pro Text'); - expect(topBackLabel.text.style.letterSpacing, -0.41); + // The top back label is styled exactly the same way. But the opacity tweens + // are flipped. + final RenderParagraph topBackLabel = + tester.renderObject(flying(tester, find.text('Page 1')).last); + expect(topBackLabel.text.style.color, const Color(0xfffffaf4)); + expect(topBackLabel.text.style.fontWeight, FontWeight.w600); + expect(topBackLabel.text.style.fontFamily, '.SF Pro Text'); + expect(topBackLabel.text.style.letterSpacing, -0.41); - checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.0); + checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.0); - // Move animation further a bit. - await tester.pump(const Duration(milliseconds: 200)); - expect(bottomMiddle.text.style.color, const Color(0xffffa01a)); - expect(bottomMiddle.text.style.fontWeight, FontWeight.w400); - expect(bottomMiddle.text.style.fontFamily, '.SF Pro Text'); - expect(bottomMiddle.text.style.letterSpacing, -0.41); + // Move animation further a bit. + await tester.pump(const Duration(milliseconds: 200)); + expect(bottomMiddle.text.style.color, const Color(0xffffa01a)); + expect(bottomMiddle.text.style.fontWeight, FontWeight.w400); + expect(bottomMiddle.text.style.fontFamily, '.SF Pro Text'); + expect(bottomMiddle.text.style.letterSpacing, -0.41); - checkOpacity(tester, flying(tester, find.text('Page 1')).first, 0.0); + checkOpacity(tester, flying(tester, find.text('Page 1')).first, 0.0); - expect(topBackLabel.text.style.color, const Color(0xffffa01a)); - expect(topBackLabel.text.style.fontWeight, FontWeight.w400); - expect(topBackLabel.text.style.fontFamily, '.SF Pro Text'); - expect(topBackLabel.text.style.letterSpacing, -0.41); + expect(topBackLabel.text.style.color, const Color(0xffffa01a)); + expect(topBackLabel.text.style.fontWeight, FontWeight.w400); + expect(topBackLabel.text.style.fontFamily, '.SF Pro Text'); + expect(topBackLabel.text.style.letterSpacing, -0.41); - checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.7630139589309692); - }); + checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.7630139589309692); + }); - testWidgets('Fullscreen dialogs do not create heroes', - (WidgetTester tester) async { + testWidgets('Fullscreen dialogs do not create heroes', (WidgetTester tester) async { await tester.pumpWidget( const CupertinoApp( home: Placeholder(), @@ -324,8 +319,7 @@ void main() { expect(() => flying(tester, find.text('Page 2')), throwsAssertionError); }); - testWidgets('Popping mid-transition is symmetrical', - (WidgetTester tester) async { + testWidgets('Popping mid-transition is symmetrical', (WidgetTester tester) async { await startTransitionBetween(tester, fromTitle: 'Page 1'); // Be mid-transition. @@ -366,8 +360,7 @@ void main() { checkColorAndPositionAt50ms(); }); - testWidgets('Popping mid-transition is symmetrical RTL', - (WidgetTester tester) async { + testWidgets('Popping mid-transition is symmetrical RTL', (WidgetTester tester) async { await startTransitionBetween( tester, fromTitle: 'Page 1', @@ -412,8 +405,7 @@ void main() { checkColorAndPositionAt50ms(); }); - testWidgets('There should be no global keys in the hero flight', - (WidgetTester tester) async { + testWidgets('There should be no global keys in the hero flight', (WidgetTester tester) async { await startTransitionBetween(tester, fromTitle: 'Page 1'); // Be mid-transition. @@ -428,8 +420,7 @@ void main() { ); }); - testWidgets('Multiple nav bars tags do not conflict if in different navigators', - (WidgetTester tester) async { + testWidgets('Multiple nav bars tags do not conflict if in different navigators', (WidgetTester tester) async { await tester.pumpWidget( CupertinoApp( home: CupertinoTabScaffold( @@ -504,8 +495,7 @@ void main() { expect(find.text('Tab 1 Page 2', skipOffstage: false), findsNothing); }); - testWidgets('Transition box grows to large title size', - (WidgetTester tester) async { + testWidgets('Transition box grows to large title size', (WidgetTester tester) async { await startTransitionBetween( tester, fromTitle: 'Page 1', @@ -529,8 +519,7 @@ void main() { checkBackgroundBoxHeight(tester, 90.53337162733078); }); - testWidgets('Large transition box shrinks to standard nav bar size', - (WidgetTester tester) async { + testWidgets('Large transition box shrinks to standard nav bar size', (WidgetTester tester) async { await startTransitionBetween( tester, from: const CupertinoSliverNavigationBar(), @@ -554,8 +543,7 @@ void main() { checkBackgroundBoxHeight(tester, 49.46662837266922); }); - testWidgets('Hero flight removed at the end of page transition', - (WidgetTester tester) async { + testWidgets('Hero flight removed at the end of page transition', (WidgetTester tester) async { await startTransitionBetween(tester, fromTitle: 'Page 1'); await tester.pump(const Duration(milliseconds: 50)); @@ -570,8 +558,7 @@ void main() { expect(() => flying(tester, find.text('Page 1')), throwsAssertionError); }); - testWidgets('Exact widget is reused to build inside the transition', - (WidgetTester tester) async { + testWidgets('Exact widget is reused to build inside the transition', (WidgetTester tester) async { const Widget userMiddle = Placeholder(); await startTransitionBetween( tester, @@ -587,8 +574,7 @@ void main() { expect(flying(tester, find.byWidget(userMiddle)), findsOneWidget); }); - testWidgets('First appearance of back chevron fades in from the right', - (WidgetTester tester) async { + testWidgets('First appearance of back chevron fades in from the right', (WidgetTester tester) async { await tester.pumpWidget( CupertinoApp( home: scaffoldForNavBar(null), @@ -624,8 +610,7 @@ void main() { tester.getTopLeft(backChevron), const Offset(23.260527312755585, 5.0)); }); - testWidgets('First appearance of back chevron fades in from the left in RTL', - (WidgetTester tester) async { + testWidgets('First appearance of back chevron fades in from the left in RTL', (WidgetTester tester) async { await tester.pumpWidget( CupertinoApp( builder: (BuildContext context, Widget navigator) { @@ -672,8 +657,7 @@ void main() { ); }); - testWidgets('Back chevron fades out and in when both pages have it', - (WidgetTester tester) async { + testWidgets('Back chevron fades out and in when both pages have it', (WidgetTester tester) async { await startTransitionBetween(tester, fromTitle: 'Page 1'); await tester.pump(const Duration(milliseconds: 50)); @@ -700,8 +684,7 @@ void main() { expect(tester.getTopLeft(backChevrons.last), const Offset(8.0, 5.0)); }); - testWidgets('Bottom middle just fades if top page has a custom leading', - (WidgetTester tester) async { + testWidgets('Bottom middle just fades if top page has a custom leading', (WidgetTester tester) async { await startTransitionBetween( tester, fromTitle: 'Page 1', @@ -784,8 +767,7 @@ void main() { ); }); - testWidgets('Bottom back label fades and slides to the left', - (WidgetTester tester) async { + testWidgets('Bottom back label fades and slides to the left', (WidgetTester tester) async { await startTransitionBetween( tester, fromTitle: 'Page 1', @@ -821,8 +803,7 @@ void main() { ); }); - testWidgets('Bottom back label fades and slides to the right in RTL', - (WidgetTester tester) async { + testWidgets('Bottom back label fades and slides to the right in RTL', (WidgetTester tester) async { await startTransitionBetween( tester, fromTitle: 'Page 1', @@ -860,8 +841,7 @@ void main() { ); }); - testWidgets('Bottom large title moves to top back label', - (WidgetTester tester) async { + testWidgets('Bottom large title moves to top back label', (WidgetTester tester) async { await startTransitionBetween( tester, from: const CupertinoSliverNavigationBar(), @@ -899,8 +879,7 @@ void main() { ); }); - testWidgets('Long title turns into the word back mid transition', - (WidgetTester tester) async { + testWidgets('Long title turns into the word back mid transition', (WidgetTester tester) async { await startTransitionBetween( tester, from: const CupertinoSliverNavigationBar(), @@ -940,8 +919,7 @@ void main() { ); }); - testWidgets('Bottom large title and top back label transitions their font', - (WidgetTester tester) async { + testWidgets('Bottom large title and top back label transitions their font', (WidgetTester tester) async { await startTransitionBetween( tester, from: const CupertinoSliverNavigationBar(), @@ -980,8 +958,7 @@ void main() { expect(topBackLabel.text.style.letterSpacing, -0.32379547566175454); }); - testWidgets('Top middle fades in and slides in from the right', - (WidgetTester tester) async { + testWidgets('Top middle fades in and slides in from the right', (WidgetTester tester) async { await startTransitionBetween( tester, toTitle: 'Page 2', @@ -1006,8 +983,7 @@ void main() { ); }); - testWidgets('Top middle fades in and slides in from the left in RTL', - (WidgetTester tester) async { + testWidgets('Top middle fades in and slides in from the left in RTL', (WidgetTester tester) async { await startTransitionBetween( tester, toTitle: 'Page 2', @@ -1033,8 +1009,7 @@ void main() { ); }); - testWidgets('Top large title fades in and slides in from the right', - (WidgetTester tester) async { + testWidgets('Top large title fades in and slides in from the right', (WidgetTester tester) async { await startTransitionBetween( tester, to: const CupertinoSliverNavigationBar(), @@ -1060,8 +1035,7 @@ void main() { ); }); - testWidgets('Top large title fades in and slides in from the left in RTL', - (WidgetTester tester) async { + testWidgets('Top large title fades in and slides in from the left in RTL', (WidgetTester tester) async { await startTransitionBetween( tester, to: const CupertinoSliverNavigationBar(), @@ -1088,8 +1062,7 @@ void main() { ); }); - testWidgets('Components are not unnecessarily rebuilt during transitions', - (WidgetTester tester) async { + testWidgets('Components are not unnecessarily rebuilt during transitions', (WidgetTester tester) async { int bottomBuildTimes = 0; int topBuildTimes = 0; await startTransitionBetween( @@ -1134,8 +1107,7 @@ void main() { expect(topBuildTimes, 3); }); - testWidgets('Back swipe gesture transitions', - (WidgetTester tester) async { + testWidgets('Back swipe gesture transitions', (WidgetTester tester) async { await startTransitionBetween( tester, fromTitle: 'Page 1', @@ -1189,8 +1161,7 @@ void main() { expect(find.text('Page 1'), findsOneWidget); }); - testWidgets('Back swipe gesture cancels properly with transition', - (WidgetTester tester) async { + testWidgets('Back swipe gesture cancels properly with transition', (WidgetTester tester) async { await startTransitionBetween( tester, fromTitle: 'Page 1', diff --git a/packages/flutter/test/cupertino/refresh_test.dart b/packages/flutter/test/cupertino/refresh_test.dart index 1a53eb7ccf..84f5908f47 100644 --- a/packages/flutter/test/cupertino/refresh_test.dart +++ b/packages/flutter/test/cupertino/refresh_test.dart @@ -36,23 +36,22 @@ void main() { refreshCompleter = Completer.sync(); refreshIndicator = Container(); - when(mockHelper.builder( - any, any, any, any, any)) - .thenAnswer((Invocation i) { - final double pulledExtent = i.positionalArguments[2]; - final double refreshTriggerPullDistance = i.positionalArguments[3]; - final double refreshIndicatorExtent = i.positionalArguments[4]; - if (pulledExtent < 0.0) { - throw TestFailure('The pulledExtent should never be less than 0.0'); - } - if (refreshTriggerPullDistance < 0.0) { - throw TestFailure('The refreshTriggerPullDistance should never be less than 0.0'); - } - if (refreshIndicatorExtent < 0.0) { - throw TestFailure('The refreshIndicatorExtent should never be less than 0.0'); - } - return refreshIndicator; - }); + when(mockHelper.builder(any, any, any, any, any)) + .thenAnswer((Invocation i) { + final double pulledExtent = i.positionalArguments[2]; + final double refreshTriggerPullDistance = i.positionalArguments[3]; + final double refreshIndicatorExtent = i.positionalArguments[4]; + if (pulledExtent < 0.0) { + throw TestFailure('The pulledExtent should never be less than 0.0'); + } + if (refreshTriggerPullDistance < 0.0) { + throw TestFailure('The refreshTriggerPullDistance should never be less than 0.0'); + } + if (refreshIndicatorExtent < 0.0) { + throw TestFailure('The refreshIndicatorExtent should never be less than 0.0'); + } + return refreshIndicator; + }); when(mockHelper.refreshTask()).thenAnswer((_) => refreshCompleter.future); }); diff --git a/packages/flutter/test/cupertino/scrollbar_test.dart b/packages/flutter/test/cupertino/scrollbar_test.dart index de7d25eb88..7e7672e52d 100644 --- a/packages/flutter/test/cupertino/scrollbar_test.dart +++ b/packages/flutter/test/cupertino/scrollbar_test.dart @@ -43,8 +43,7 @@ void main() { )); }); - testWidgets('Scrollbar is not smaller than minLength with large scroll views', - (WidgetTester tester) async { + testWidgets('Scrollbar is not smaller than minLength with large scroll views', (WidgetTester tester) async { await tester.pumpWidget(const Directionality( textDirection: TextDirection.ltr, child: CupertinoScrollbar( diff --git a/packages/flutter/test/cupertino/segmented_control_test.dart b/packages/flutter/test/cupertino/segmented_control_test.dart index 78827adea5..20caee9b61 100644 --- a/packages/flutter/test/cupertino/segmented_control_test.dart +++ b/packages/flutter/test/cupertino/segmented_control_test.dart @@ -119,8 +119,7 @@ void main() { } }); - testWidgets('Value attribute must be the key of one of the children widgets', - (WidgetTester tester) async { + testWidgets('Value attribute must be the key of one of the children widgets', (WidgetTester tester) async { final Map children = {}; children[0] = const Text('Child 1'); children[1] = const Text('Child 2'); @@ -142,8 +141,7 @@ void main() { } }); - testWidgets('Children and onValueChanged arguments can not be null', - (WidgetTester tester) async { + testWidgets('Children and onValueChanged arguments can not be null', (WidgetTester tester) async { try { await tester.pumpWidget( boilerplate( @@ -177,8 +175,7 @@ void main() { } }); - testWidgets('Widgets have correct default text/icon styles, change correctly on selection', - (WidgetTester tester) async { + testWidgets('Widgets have correct default text/icon styles, change correctly on selection', (WidgetTester tester) async { final Map children = {}; children[0] = const Text('Child 1'); children[1] = const Icon(IconData(1)); @@ -267,8 +264,7 @@ void main() { }, ); - testWidgets('SegmentedControl is correct when user provides custom colors', - (WidgetTester tester) async { + testWidgets('SegmentedControl is correct when user provides custom colors', (WidgetTester tester) async { final Map children = {}; children[0] = const Text('Child 1'); children[1] = const Icon(IconData(1)); @@ -293,7 +289,7 @@ void main() { pressedColor: const Color(0x638CFC7B), ), ); - }, + }, ), ); @@ -381,8 +377,7 @@ void main() { expect(value, isTrue); }); - testWidgets('State does not change if onValueChanged does not call setState()', - (WidgetTester tester) async { + testWidgets('State does not change if onValueChanged does not call setState()', (WidgetTester tester) async { final Map children = {}; children[0] = const Text('Child 1'); children[1] = const Text('Child 2'); @@ -464,8 +459,7 @@ void main() { }, ); - testWidgets('Passed in value is child initially selected', - (WidgetTester tester) async { + testWidgets('Passed in value is child initially selected', (WidgetTester tester) async { await tester.pumpWidget(setupSimpleSegmentedControl()); expect(getRenderSegmentedControl(tester).selectedIndex, 0); @@ -474,8 +468,7 @@ void main() { expect(getBackgroundColor(tester, 1), CupertinoColors.white); }); - testWidgets('Null input for value results in no child initially selected', - (WidgetTester tester) async { + testWidgets('Null input for value results in no child initially selected', (WidgetTester tester) async { final Map children = {}; children[0] = const Text('Child 1'); children[1] = const Text('Child 2'); @@ -506,8 +499,7 @@ void main() { expect(getBackgroundColor(tester, 1), CupertinoColors.white); }); - testWidgets('Long press changes background color of not-selected child', - (WidgetTester tester) async { + testWidgets('Long press changes background color of not-selected child', (WidgetTester tester) async { await tester.pumpWidget(setupSimpleSegmentedControl()); expect(getBackgroundColor(tester, 0), CupertinoColors.activeBlue); @@ -521,8 +513,7 @@ void main() { expect(getBackgroundColor(tester, 1), const Color(0x33007aff)); }); - testWidgets('Long press does not change background color of currently-selected child', - (WidgetTester tester) async { + testWidgets('Long press does not change background color of currently-selected child', (WidgetTester tester) async { await tester.pumpWidget(setupSimpleSegmentedControl()); expect(getBackgroundColor(tester, 0), CupertinoColors.activeBlue); @@ -536,8 +527,7 @@ void main() { expect(getBackgroundColor(tester, 1), CupertinoColors.white); }); - testWidgets('Height of segmented control is determined by tallest widget', - (WidgetTester tester) async { + testWidgets('Height of segmented control is determined by tallest widget', (WidgetTester tester) async { final Map children = {}; children[0] = Container( constraints: const BoxConstraints.tightFor(height: 100.0), @@ -569,8 +559,7 @@ void main() { expect(buttonBox.size.height, 400.0); }); - testWidgets('Width of each segmented control segment is determined by widest widget', - (WidgetTester tester) async { + testWidgets('Width of each segmented control segment is determined by widest widget', (WidgetTester tester) async { final Map children = {}; children[0] = Container( constraints: const BoxConstraints.tightFor(width: 50.0), @@ -642,8 +631,7 @@ void main() { expect(segmentedControl.size.width.isFinite, isTrue); }); - testWidgets('Directionality test - RTL should reverse order of widgets', - (WidgetTester tester) async { + testWidgets('Directionality test - RTL should reverse order of widgets', (WidgetTester tester) async { final Map children = {}; children[0] = const Text('Child 1'); children[1] = const Text('Child 2'); @@ -664,8 +652,7 @@ void main() { tester.getTopRight(find.text('Child 2')).dx, isTrue); }); - testWidgets('Correct initial selection and toggling behavior - RTL', - (WidgetTester tester) async { + testWidgets('Correct initial selection and toggling behavior - RTL', (WidgetTester tester) async { final Map children = {}; children[0] = const Text('Child 1'); children[1] = const Text('Child 2'); @@ -852,8 +839,7 @@ void main() { expect(sharedValue, 0); }); - testWidgets('Animation is correct when the selected segment changes', - (WidgetTester tester) async { + testWidgets('Animation is correct when the selected segment changes', (WidgetTester tester) async { await tester.pumpWidget(setupSimpleSegmentedControl()); await tester.tap(find.text('Child 2')); @@ -1077,8 +1063,7 @@ void main() { expect(getBackgroundColor(tester, 2), CupertinoColors.white); }); - testWidgets('Transition is triggered while a transition is already occurring', - (WidgetTester tester) async { + testWidgets('Transition is triggered while a transition is already occurring', (WidgetTester tester) async { final Map children = {}; children[0] = const Text('A'); children[1] = const Text('B'); @@ -1140,8 +1125,7 @@ void main() { expect(getBackgroundColor(tester, 2), CupertinoColors.activeBlue); }); - testWidgets('Segment is selected while it is transitioning to unselected state', - (WidgetTester tester) async { + testWidgets('Segment is selected while it is transitioning to unselected state', (WidgetTester tester) async { await tester.pumpWidget(setupSimpleSegmentedControl()); await tester.tap(find.text('Child 2')); diff --git a/packages/flutter/test/cupertino/text_field_test.dart b/packages/flutter/test/cupertino/text_field_test.dart index 7e9af7fcaf..aa199c1ac9 100644 --- a/packages/flutter/test/cupertino/text_field_test.dart +++ b/packages/flutter/test/cupertino/text_field_test.dart @@ -1372,91 +1372,91 @@ void main() { testWidgets('long press drag can edge scroll', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( - text: 'Atwater Peel Sherbrooke Bonaventure Angrignon Peel Côte-des-Neiges', - ); - await tester.pumpWidget( - CupertinoApp( - home: Center( - child: CupertinoTextField( - controller: controller, - maxLines: 1, - ), + text: 'Atwater Peel Sherbrooke Bonaventure Angrignon Peel Côte-des-Neiges', + ); + await tester.pumpWidget( + CupertinoApp( + home: Center( + child: CupertinoTextField( + controller: controller, + maxLines: 1, ), ), - ); + ), + ); - final RenderEditable renderEditable = tester.renderObject( - find.byElementPredicate((Element element) => element.renderObject is RenderEditable) - ); + final RenderEditable renderEditable = tester.renderObject( + find.byElementPredicate((Element element) => element.renderObject is RenderEditable) + ); - List lastCharEndpoint = renderEditable.getEndpointsForSelection( - const TextSelection.collapsed(offset: 66), // Last character's position. - ); + List lastCharEndpoint = renderEditable.getEndpointsForSelection( + const TextSelection.collapsed(offset: 66), // Last character's position. + ); - expect(lastCharEndpoint.length, 1); - // Just testing the test and making sure that the last character is off - // the right side of the screen. - expect(lastCharEndpoint[0].point.dx, moreOrLessEquals(1094.73486328125)); + expect(lastCharEndpoint.length, 1); + // Just testing the test and making sure that the last character is off + // the right side of the screen. + expect(lastCharEndpoint[0].point.dx, moreOrLessEquals(1094.73486328125)); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); - final TestGesture gesture = - await tester.startGesture(textfieldStart + const Offset(300, 5)); - await tester.pump(const Duration(milliseconds: 500)); + final TestGesture gesture = + await tester.startGesture(textfieldStart + const Offset(300, 5)); + await tester.pump(const Duration(milliseconds: 500)); - expect( - controller.selection, - const TextSelection.collapsed(offset: 18, affinity: TextAffinity.upstream), - ); - expect(find.byType(CupertinoButton), findsNothing); + expect( + controller.selection, + const TextSelection.collapsed(offset: 18, affinity: TextAffinity.upstream), + ); + expect(find.byType(CupertinoButton), findsNothing); - await gesture.moveBy(const Offset(600, 0)); - // To the edge of the screen basically. - await tester.pump(); - expect( - controller.selection, - const TextSelection.collapsed(offset: 54, affinity: TextAffinity.upstream), - ); - // Keep moving out. - await gesture.moveBy(const Offset(1, 0)); - await tester.pump(); - expect( - controller.selection, - const TextSelection.collapsed(offset: 61, affinity: TextAffinity.upstream), - ); - await gesture.moveBy(const Offset(1, 0)); - await tester.pump(); - expect( - controller.selection, - const TextSelection.collapsed(offset: 66, affinity: TextAffinity.upstream), - ); // We're at the edge now. - expect(find.byType(CupertinoButton), findsNothing); + await gesture.moveBy(const Offset(600, 0)); + // To the edge of the screen basically. + await tester.pump(); + expect( + controller.selection, + const TextSelection.collapsed(offset: 54, affinity: TextAffinity.upstream), + ); + // Keep moving out. + await gesture.moveBy(const Offset(1, 0)); + await tester.pump(); + expect( + controller.selection, + const TextSelection.collapsed(offset: 61, affinity: TextAffinity.upstream), + ); + await gesture.moveBy(const Offset(1, 0)); + await tester.pump(); + expect( + controller.selection, + const TextSelection.collapsed(offset: 66, affinity: TextAffinity.upstream), + ); // We're at the edge now. + expect(find.byType(CupertinoButton), findsNothing); - await gesture.up(); - await tester.pump(); + await gesture.up(); + await tester.pump(); - // The selection isn't affected by the gesture lift. - expect( - controller.selection, - const TextSelection.collapsed(offset: 66, affinity: TextAffinity.upstream), - ); - // The toolbar now shows up. - expect(find.byType(CupertinoButton), findsNWidgets(2)); + // The selection isn't affected by the gesture lift. + expect( + controller.selection, + const TextSelection.collapsed(offset: 66, affinity: TextAffinity.upstream), + ); + // The toolbar now shows up. + expect(find.byType(CupertinoButton), findsNWidgets(2)); - lastCharEndpoint = renderEditable.getEndpointsForSelection( - const TextSelection.collapsed(offset: 66), // Last character's position. - ); + lastCharEndpoint = renderEditable.getEndpointsForSelection( + const TextSelection.collapsed(offset: 66), // Last character's position. + ); - expect(lastCharEndpoint.length, 1); - // The last character is now on screen. - expect(lastCharEndpoint[0].point.dx, moreOrLessEquals(786.73486328125)); + expect(lastCharEndpoint.length, 1); + // The last character is now on screen. + expect(lastCharEndpoint[0].point.dx, moreOrLessEquals(786.73486328125)); - final List firstCharEndpoint = renderEditable.getEndpointsForSelection( - const TextSelection.collapsed(offset: 0), // First character's position. - ); - expect(firstCharEndpoint.length, 1); - // The first character is now offscreen to the left. - expect(firstCharEndpoint[0].point.dx, moreOrLessEquals(-308.20499999821186)); + final List firstCharEndpoint = renderEditable.getEndpointsForSelection( + const TextSelection.collapsed(offset: 0), // First character's position. + ); + expect(firstCharEndpoint.length, 1); + // The first character is now offscreen to the left. + expect(firstCharEndpoint[0].point.dx, moreOrLessEquals(-308.20499999821186)); }); testWidgets( diff --git a/packages/flutter/test/foundation/caching_iterable_test.dart b/packages/flutter/test/foundation/caching_iterable_test.dart index fa6a10dc4b..c8d1f65a5a 100644 --- a/packages/flutter/test/foundation/caching_iterable_test.dart +++ b/packages/flutter/test/foundation/caching_iterable_test.dart @@ -14,7 +14,7 @@ Iterable range(int start, int end) sync* { yieldCount += 1; yield index; } - } +} void main() { setUp(() { diff --git a/packages/flutter/test/foundation/consolidate_response_test.dart b/packages/flutter/test/foundation/consolidate_response_test.dart index 49f84cd7da..cd1d84d73d 100644 --- a/packages/flutter/test/foundation/consolidate_response_test.dart +++ b/packages/flutter/test/foundation/consolidate_response_test.dart @@ -18,7 +18,7 @@ void main() { setUp(() { response = MockHttpClientResponse(); - when(response.listen( + when(response.listen( any, onDone: anyNamed('onDone'), onError: anyNamed('onError'), @@ -39,8 +39,7 @@ void main() { }); }); - test('Converts an HttpClientResponse with contentLength to bytes', - () async { + test('Converts an HttpClientResponse with contentLength to bytes', () async { when(response.contentLength) .thenReturn(chunkOne.length + chunkTwo.length); final List bytes = @@ -49,8 +48,7 @@ void main() { expect(bytes, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); }); - test('Converts a compressed HttpClientResponse with contentLength to bytes', - () async { + test('Converts a compressed HttpClientResponse with contentLength to bytes', () async { when(response.contentLength).thenReturn(chunkOne.length); final List bytes = await consolidateHttpClientResponseBytes(response); @@ -58,8 +56,7 @@ void main() { expect(bytes, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); }); - test('Converts an HttpClientResponse without contentLength to bytes', - () async { + test('Converts an HttpClientResponse without contentLength to bytes', () async { when(response.contentLength).thenReturn(-1); final List bytes = await consolidateHttpClientResponseBytes(response); diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index e9b9846664..0a37c27063 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -244,30 +244,9 @@ void main() { testWidgets( 'AppBar centerTitle:false leading button title left edge is 72.0 (LTR)', (WidgetTester tester) async { - await tester.pumpWidget( - MaterialApp( - home: Scaffold( - appBar: AppBar( - centerTitle: false, - title: const Text('X'), - ), - // A drawer causes a leading hamburger. - drawer: const Drawer(), - ), - ), - ); - - expect(tester.getTopLeft(find.text('X')).dx, 72.0); - }); - - testWidgets( - 'AppBar centerTitle:false leading button title left edge is 72.0 (RTL)', - (WidgetTester tester) async { - await tester.pumpWidget( - MaterialApp( - home: Directionality( - textDirection: TextDirection.rtl, - child: Scaffold( + await tester.pumpWidget( + MaterialApp( + home: Scaffold( appBar: AppBar( centerTitle: false, title: const Text('X'), @@ -276,11 +255,32 @@ void main() { drawer: const Drawer(), ), ), - ), - ); + ); - expect(tester.getTopRight(find.text('X')).dx, 800.0 - 72.0); - }); + expect(tester.getTopLeft(find.text('X')).dx, 72.0); + }); + + testWidgets( + 'AppBar centerTitle:false leading button title left edge is 72.0 (RTL)', + (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + home: Directionality( + textDirection: TextDirection.rtl, + child: Scaffold( + appBar: AppBar( + centerTitle: false, + title: const Text('X'), + ), + // A drawer causes a leading hamburger. + drawer: const Drawer(), + ), + ), + ), + ); + + expect(tester.getTopRight(find.text('X')).dx, 800.0 - 72.0); + }); testWidgets('AppBar centerTitle:false title overflow OK', (WidgetTester tester) async { // The app bar's title should be constrained to fit within the available space diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index 6d28346960..76f1206de4 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -1154,8 +1154,7 @@ void main() { } }); - testWidgets('BottomNavigationBar item title should not be nullable', - (WidgetTester tester) async { + testWidgets('BottomNavigationBar item title should not be nullable', (WidgetTester tester) async { expect(() { MaterialApp( home: Scaffold( @@ -1173,16 +1172,55 @@ void main() { }, throwsA(isInstanceOf())); }); - testWidgets('BottomNavigationBar [showSelectedLabels]=false and [showUnselectedLabels]=false ' - 'for shifting navbar, expect that there is no rendered text', (WidgetTester tester) async { - final Widget widget = MaterialApp( + testWidgets( + 'BottomNavigationBar [showSelectedLabels]=false and [showUnselectedLabels]=false ' + 'for shifting navbar, expect that there is no rendered text', + (WidgetTester tester) async { + final Widget widget = MaterialApp( + home: StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return Scaffold( + bottomNavigationBar: BottomNavigationBar( + showSelectedLabels: false, + showUnselectedLabels: false, + type: BottomNavigationBarType.shifting, + items: const [ + BottomNavigationBarItem( + title: Text('Red'), + backgroundColor: Colors.red, + icon: Icon(Icons.dashboard), + ), + BottomNavigationBarItem( + title: Text('Green'), + backgroundColor: Colors.green, + icon: Icon(Icons.menu), + ), + ], + ), + ); + }, + ), + ); + await tester.pumpWidget(widget); + expect(find.text('Red'), findsOneWidget); + expect(find.text('Green'), findsOneWidget); + expect(tester.widget(find.byType(Opacity).first).opacity, 0.0); + expect(tester.widget(find.byType(Opacity).last).opacity, 0.0); + }); + + testWidgets( + 'BottomNavigationBar [showSelectedLabels]=false and [showUnselectedLabels]=false ' + 'for fixed navbar, expect that there is no rendered text', + (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( home: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return Scaffold( bottomNavigationBar: BottomNavigationBar( showSelectedLabels: false, showUnselectedLabels: false, - type: BottomNavigationBarType.shifting, + type: BottomNavigationBarType.fixed, items: const [ BottomNavigationBarItem( title: Text('Red'), @@ -1199,48 +1237,13 @@ void main() { ); }, ), - ); - await tester.pumpWidget(widget); - expect(find.text('Red'), findsOneWidget); - expect(find.text('Green'), findsOneWidget); - expect(tester.widget(find.byType(Opacity).first).opacity, 0.0); - expect(tester.widget(find.byType(Opacity).last).opacity, 0.0); - }); - - testWidgets('BottomNavigationBar [showSelectedLabels]=false and [showUnselectedLabels]=false ' - 'for fixed navbar, expect that there is no rendered text', (WidgetTester tester) async { - await tester.pumpWidget( - MaterialApp( - home: StatefulBuilder( - builder: (BuildContext context, StateSetter setState) { - return Scaffold( - bottomNavigationBar: BottomNavigationBar( - showSelectedLabels: false, - showUnselectedLabels: false, - type: BottomNavigationBarType.fixed, - items: const [ - BottomNavigationBarItem( - title: Text('Red'), - backgroundColor: Colors.red, - icon: Icon(Icons.dashboard), - ), - BottomNavigationBarItem( - title: Text('Green'), - backgroundColor: Colors.green, - icon: Icon(Icons.menu), - ), - ], - ), - ); - }, - ), - ), - ); - expect(find.text('Red'), findsOneWidget); - expect(find.text('Green'), findsOneWidget); - expect(tester.widget(find.byType(Opacity).first).opacity, 0.0); - expect(tester.widget(find.byType(Opacity).last).opacity, 0.0); - }); + ), + ); + expect(find.text('Red'), findsOneWidget); + expect(find.text('Green'), findsOneWidget); + expect(tester.widget(find.byType(Opacity).first).opacity, 0.0); + expect(tester.widget(find.byType(Opacity).last).opacity, 0.0); + }); testWidgets('BottomNavigationBar.fixed [showSelectedLabels]=false and [showUnselectedLabels]=false semantics', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); diff --git a/packages/flutter/test/material/chip_test.dart b/packages/flutter/test/material/chip_test.dart index c0635f2b85..42c7f97840 100644 --- a/packages/flutter/test/material/chip_test.dart +++ b/packages/flutter/test/material/chip_test.dart @@ -1583,12 +1583,12 @@ void main() { } testWidgets('Chip clipBehavior properly passes through to the Material', (WidgetTester tester) async { - const Text label = Text('label'); - await tester.pumpWidget(_wrapForChip(child: const Chip(label: label))); - checkChipMaterialClipBehavior(tester, Clip.none); + const Text label = Text('label'); + await tester.pumpWidget(_wrapForChip(child: const Chip(label: label))); + checkChipMaterialClipBehavior(tester, Clip.none); - await tester.pumpWidget(_wrapForChip(child: const Chip(label: label, clipBehavior: Clip.antiAlias))); - checkChipMaterialClipBehavior(tester, Clip.antiAlias); + await tester.pumpWidget(_wrapForChip(child: const Chip(label: label, clipBehavior: Clip.antiAlias))); + checkChipMaterialClipBehavior(tester, Clip.antiAlias); }); testWidgets('ChoiceChip clipBehavior properly passes through to the Material', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart index 856c38e0e1..c405698a6c 100644 --- a/packages/flutter/test/material/dialog_test.dart +++ b/packages/flutter/test/material/dialog_test.dart @@ -24,7 +24,7 @@ MaterialApp _appWithAlertDialog(WidgetTester tester, AlertDialog dialog, { Theme showDialog( context: context, builder: (BuildContext context) { - return dialog; + return dialog; }, ); }, diff --git a/packages/flutter/test/material/floating_action_button_location_test.dart b/packages/flutter/test/material/floating_action_button_location_test.dart index 00eb396473..9777747c1c 100644 --- a/packages/flutter/test/material/floating_action_button_location_test.dart +++ b/packages/flutter/test/material/floating_action_button_location_test.dart @@ -77,7 +77,7 @@ void main() { }); group('interrupts in-progress animations without jumps', () { - _GeometryListener geometryListener; + _GeometryListener geometryListener; ScaffoldGeometry geometry; _GeometryListenerState listenerState; Size previousRect; diff --git a/packages/flutter/test/material/icon_button_test.dart b/packages/flutter/test/material/icon_button_test.dart index dce6cc56df..c3d310d395 100644 --- a/packages/flutter/test/material/icon_button_test.dart +++ b/packages/flutter/test/material/icon_button_test.dart @@ -90,9 +90,7 @@ void main() { expect(box.size, const Size(80.0, 80.0)); }); - testWidgets( - 'test default icon buttons can be stretched if specified', - (WidgetTester tester) async { + testWidgets('test default icon buttons can be stretched if specified', (WidgetTester tester) async { await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index 44e75e88c0..5e947ac625 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -630,7 +630,7 @@ void main() { await tester.pumpWidget(buildFrame(extendBody: false, resizeToAvoidBottomInset: true, viewInsetBottom: 100.0)); expect(tester.getSize(find.byKey(bodyKey)), const Size(800.0, 500.0)); expect(mediaQueryBottom, 0.0); - }); + }); }); testWidgets('Open drawer hides underlying semantics tree', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/search_test.dart b/packages/flutter/test/material/search_test.dart index 4f2e034ccf..1679ad1a62 100644 --- a/packages/flutter/test/material/search_test.dart +++ b/packages/flutter/test/material/search_test.dart @@ -156,8 +156,7 @@ void main() { expect(selectedResults, ['Result']); }); - testWidgets('Can switch between results and suggestions', - (WidgetTester tester) async { + testWidgets('Can switch between results and suggestions', (WidgetTester tester) async { final _TestSearchDelegate delegate = _TestSearchDelegate(); await tester.pumpWidget(TestHomePage( @@ -227,8 +226,7 @@ void main() { expect(textField.focusNode.hasFocus, isFalse); }); - testWidgets('Fresh search allways starts with empty query', - (WidgetTester tester) async { + testWidgets('Fresh search allways starts with empty query', (WidgetTester tester) async { final _TestSearchDelegate delegate = _TestSearchDelegate(); await tester.pumpWidget(TestHomePage( diff --git a/packages/flutter/test/material/slider_test.dart b/packages/flutter/test/material/slider_test.dart index f855df6636..869a7a22d8 100644 --- a/packages/flutter/test/material/slider_test.dart +++ b/packages/flutter/test/material/slider_test.dart @@ -556,10 +556,10 @@ void main() { bool enabled = true, }) { final ValueChanged onChanged = !enabled - ? null - : (double d) { - value = d; - }; + ? null + : (double d) { + value = d; + }; return Directionality( textDirection: TextDirection.ltr, child: MediaQuery( diff --git a/packages/flutter/test/material/snack_bar_test.dart b/packages/flutter/test/material/snack_bar_test.dart index 5c7f0e7d7b..e817af1aeb 100644 --- a/packages/flutter/test/material/snack_bar_test.dart +++ b/packages/flutter/test/material/snack_bar_test.dart @@ -527,44 +527,44 @@ void main() { }); testWidgets('accessible navigation behavior with action', (WidgetTester tester) async { - final GlobalKey scaffoldKey = GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); - await tester.pumpWidget(MaterialApp( - home: MediaQuery( - data: const MediaQueryData(accessibleNavigation: true), - child: Scaffold( - key: scaffoldKey, - body: Builder( - builder: (BuildContext context) { - return GestureDetector( - onTap: () { - Scaffold.of(context).showSnackBar(SnackBar( - content: const Text('snack'), - duration: const Duration(seconds: 1), - action: SnackBarAction( - label: 'ACTION', - onPressed: () {}, - ), - )); - }, - child: const Text('X'), - ); - }, - ), + await tester.pumpWidget(MaterialApp( + home: MediaQuery( + data: const MediaQueryData(accessibleNavigation: true), + child: Scaffold( + key: scaffoldKey, + body: Builder( + builder: (BuildContext context) { + return GestureDetector( + onTap: () { + Scaffold.of(context).showSnackBar(SnackBar( + content: const Text('snack'), + duration: const Duration(seconds: 1), + action: SnackBarAction( + label: 'ACTION', + onPressed: () {}, + ), + )); + }, + child: const Text('X'), + ); + }, ), ), - )); - await tester.tap(find.text('X')); - await tester.pump(); - // Find action immediately - expect(find.text('ACTION'), findsOneWidget); - // Snackbar doesn't close - await tester.pump(const Duration(seconds: 10)); - expect(find.text('ACTION'), findsOneWidget); - await tester.tap(find.text('ACTION')); - await tester.pump(); - // Snackbar closes immediately - expect(find.text('ACTION'), findsNothing); + ), + )); + await tester.tap(find.text('X')); + await tester.pump(); + // Find action immediately + expect(find.text('ACTION'), findsOneWidget); + // Snackbar doesn't close + await tester.pump(const Duration(seconds: 10)); + expect(find.text('ACTION'), findsOneWidget); + await tester.tap(find.text('ACTION')); + await tester.pump(); + // Snackbar closes immediately + expect(find.text('ACTION'), findsNothing); }); testWidgets('contributes dismiss semantics', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/switch_test.dart b/packages/flutter/test/material/switch_test.dart index 4214de4d2b..0742a5623d 100644 --- a/packages/flutter/test/material/switch_test.dart +++ b/packages/flutter/test/material/switch_test.dart @@ -146,13 +146,12 @@ void main() { return Material( child: Center( child: Switch( - dragStartBehavior: DragStartBehavior.down, - value: value, - onChanged: (bool newValue) { - setState(() { - value = newValue; - } - ); + dragStartBehavior: DragStartBehavior.down, + value: value, + onChanged: (bool newValue) { + setState(() { + value = newValue; + }); }, ), ), diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 09e37a9188..d51e41c6a0 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -1372,8 +1372,7 @@ void main() { expect(suffixText.style, suffixStyle); }); - testWidgets('TextField prefix and suffix appear correctly with no hint or label', - (WidgetTester tester) async { + testWidgets('TextField prefix and suffix appear correctly with no hint or label', (WidgetTester tester) async { final Key secondKey = UniqueKey(); await tester.pumpWidget( @@ -1416,8 +1415,7 @@ void main() { expect(find.text('Suffix'), findsOneWidget); }); - testWidgets('TextField prefix and suffix appear correctly with hint text', - (WidgetTester tester) async { + testWidgets('TextField prefix and suffix appear correctly with hint text', (WidgetTester tester) async { final TextStyle hintStyle = TextStyle( inherit: false, color: Colors.pink[500], @@ -1477,8 +1475,7 @@ void main() { expect(suffixText.style, hintStyle); }); - testWidgets('TextField prefix and suffix appear correctly with label text', - (WidgetTester tester) async { + testWidgets('TextField prefix and suffix appear correctly with label text', (WidgetTester tester) async { final TextStyle prefixStyle = TextStyle( color: Colors.pink[500], fontSize: 10.0, @@ -2124,9 +2121,7 @@ void main() { expect(find.text('5/10'), findsOneWidget); }); - testWidgets( - 'setting maxLength to TextField.noMaxLength shows only entered length', - (WidgetTester tester) async { + testWidgets('setting maxLength to TextField.noMaxLength shows only entered length', (WidgetTester tester) async { await tester.pumpWidget(const MaterialApp( home: Material( child: Center( @@ -2361,13 +2356,13 @@ void main() { String clipboardContent = ''; SystemChannels.platform - .setMockMethodCallHandler((MethodCall methodCall) async { - if (methodCall.method == 'Clipboard.setData') - clipboardContent = methodCall.arguments['text']; - else if (methodCall.method == 'Clipboard.getData') - return {'text': clipboardContent}; - return null; - }); + .setMockMethodCallHandler((MethodCall methodCall) async { + if (methodCall.method == 'Clipboard.setData') + clipboardContent = methodCall.arguments['text']; + else if (methodCall.method == 'Clipboard.getData') + return {'text': clipboardContent}; + return null; + }); await tester.pumpWidget( MaterialApp( @@ -2431,13 +2426,13 @@ void main() { ); String clipboardContent = ''; SystemChannels.platform - .setMockMethodCallHandler((MethodCall methodCall) async { - if (methodCall.method == 'Clipboard.setData') - clipboardContent = methodCall.arguments['text']; - else if (methodCall.method == 'Clipboard.getData') - return {'text': clipboardContent}; - return null; - }); + .setMockMethodCallHandler((MethodCall methodCall) async { + if (methodCall.method == 'Clipboard.setData') + clipboardContent = methodCall.arguments['text']; + else if (methodCall.method == 'Clipboard.getData') + return {'text': clipboardContent}; + return null; + }); await tester.pumpWidget( MaterialApp( @@ -2603,7 +2598,7 @@ void main() { final Key key1 = UniqueKey(); final Key key2 = UniqueKey(); - await tester.pumpWidget( + await tester.pumpWidget( MaterialApp( home: Material( @@ -4407,92 +4402,92 @@ void main() { testWidgets('long press drag can edge scroll (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( - text: 'Atwater Peel Sherbrooke Bonaventure Angrignon Peel Côte-des-Neiges', - ); - await tester.pumpWidget( - MaterialApp( - theme: ThemeData(platform: TargetPlatform.iOS), - home: Material( - child: Center( - child: TextField( - controller: controller, - maxLines: 1, - ), + text: 'Atwater Peel Sherbrooke Bonaventure Angrignon Peel Côte-des-Neiges', + ); + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: Material( + child: Center( + child: TextField( + controller: controller, + maxLines: 1, ), ), ), - ); + ), + ); - final RenderEditable renderEditable = findRenderEditable(tester); + final RenderEditable renderEditable = findRenderEditable(tester); - List lastCharEndpoint = renderEditable.getEndpointsForSelection( - const TextSelection.collapsed(offset: 66), // Last character's position. - ); + List lastCharEndpoint = renderEditable.getEndpointsForSelection( + const TextSelection.collapsed(offset: 66), // Last character's position. + ); - expect(lastCharEndpoint.length, 1); - // Just testing the test and making sure that the last character is off - // the right side of the screen. - expect(lastCharEndpoint[0].point.dx, 1056); + expect(lastCharEndpoint.length, 1); + // Just testing the test and making sure that the last character is off + // the right side of the screen. + expect(lastCharEndpoint[0].point.dx, 1056); - final Offset textfieldStart = tester.getTopLeft(find.byType(TextField)); + final Offset textfieldStart = tester.getTopLeft(find.byType(TextField)); - final TestGesture gesture = - await tester.startGesture(textfieldStart + const Offset(300, 5)); - await tester.pump(const Duration(milliseconds: 500)); + final TestGesture gesture = + await tester.startGesture(textfieldStart + const Offset(300, 5)); + await tester.pump(const Duration(milliseconds: 500)); - expect( - controller.selection, - const TextSelection.collapsed(offset: 19, affinity: TextAffinity.upstream), - ); - expect(find.byType(CupertinoButton), findsNothing); + expect( + controller.selection, + const TextSelection.collapsed(offset: 19, affinity: TextAffinity.upstream), + ); + expect(find.byType(CupertinoButton), findsNothing); - await gesture.moveBy(const Offset(600, 0)); - // To the edge of the screen basically. - await tester.pump(); - expect( - controller.selection, - const TextSelection.collapsed(offset: 56, affinity: TextAffinity.downstream), - ); - // Keep moving out. - await gesture.moveBy(const Offset(1, 0)); - await tester.pump(); - expect( - controller.selection, - const TextSelection.collapsed(offset: 62, affinity: TextAffinity.downstream), - ); - await gesture.moveBy(const Offset(1, 0)); - await tester.pump(); - expect( - controller.selection, - const TextSelection.collapsed(offset: 66, affinity: TextAffinity.upstream), - ); // We're at the edge now. - expect(find.byType(CupertinoButton), findsNothing); + await gesture.moveBy(const Offset(600, 0)); + // To the edge of the screen basically. + await tester.pump(); + expect( + controller.selection, + const TextSelection.collapsed(offset: 56, affinity: TextAffinity.downstream), + ); + // Keep moving out. + await gesture.moveBy(const Offset(1, 0)); + await tester.pump(); + expect( + controller.selection, + const TextSelection.collapsed(offset: 62, affinity: TextAffinity.downstream), + ); + await gesture.moveBy(const Offset(1, 0)); + await tester.pump(); + expect( + controller.selection, + const TextSelection.collapsed(offset: 66, affinity: TextAffinity.upstream), + ); // We're at the edge now. + expect(find.byType(CupertinoButton), findsNothing); - await gesture.up(); - await tester.pump(); + await gesture.up(); + await tester.pump(); - // The selection isn't affected by the gesture lift. - expect( - controller.selection, - const TextSelection.collapsed(offset: 66, affinity: TextAffinity.upstream), - ); - // The toolbar now shows up. - expect(find.byType(CupertinoButton), findsNWidgets(2)); + // The selection isn't affected by the gesture lift. + expect( + controller.selection, + const TextSelection.collapsed(offset: 66, affinity: TextAffinity.upstream), + ); + // The toolbar now shows up. + expect(find.byType(CupertinoButton), findsNWidgets(2)); - lastCharEndpoint = renderEditable.getEndpointsForSelection( - const TextSelection.collapsed(offset: 66), // Last character's position. - ); + lastCharEndpoint = renderEditable.getEndpointsForSelection( + const TextSelection.collapsed(offset: 66), // Last character's position. + ); - expect(lastCharEndpoint.length, 1); - // The last character is now on screen near the right edge. - expect(lastCharEndpoint[0].point.dx, moreOrLessEquals(798, epsilon: 1)); + expect(lastCharEndpoint.length, 1); + // The last character is now on screen near the right edge. + expect(lastCharEndpoint[0].point.dx, moreOrLessEquals(798, epsilon: 1)); - final List firstCharEndpoint = renderEditable.getEndpointsForSelection( - const TextSelection.collapsed(offset: 0), // First character's position. - ); - expect(firstCharEndpoint.length, 1); - // The first character is now offscreen to the left. - expect(firstCharEndpoint[0].point.dx, moreOrLessEquals(-257, epsilon: 1)); + final List firstCharEndpoint = renderEditable.getEndpointsForSelection( + const TextSelection.collapsed(offset: 0), // First character's position. + ); + expect(firstCharEndpoint.length, 1); + // The first character is now offscreen to the left. + expect(firstCharEndpoint[0].point.dx, moreOrLessEquals(-257, epsilon: 1)); }); testWidgets( diff --git a/packages/flutter/test/painting/box_decoration_test.dart b/packages/flutter/test/painting/box_decoration_test.dart index c4728336ef..e24dae575e 100644 --- a/packages/flutter/test/painting/box_decoration_test.dart +++ b/packages/flutter/test/painting/box_decoration_test.dart @@ -58,7 +58,7 @@ void main() { final BoxPainter painter = decoration.createBoxPainter(); const Size size = Size(1000.0, 1000.0); expect( - (Canvas canvas) { + (Canvas canvas) { painter.paint( canvas, const Offset(0.0, 0.0), diff --git a/packages/flutter/test/painting/image_cache_resize_test.dart b/packages/flutter/test/painting/image_cache_resize_test.dart index 1cf3ff44cb..0c8139f5bf 100644 --- a/packages/flutter/test/painting/image_cache_resize_test.dart +++ b/packages/flutter/test/painting/image_cache_resize_test.dart @@ -11,69 +11,69 @@ import 'mocks_for_image_cache.dart'; void main() { TestRenderingFlutterBinding(); // initializes the imageCache group(ImageCache, () { - tearDown(() { - imageCache.clear(); - imageCache.maximumSize = 1000; - imageCache.maximumSizeBytes = 10485760; - }); + tearDown(() { + imageCache.clear(); + imageCache.maximumSize = 1000; + imageCache.maximumSizeBytes = 10485760; + }); - test('Image cache resizing based on count', () async { - imageCache.maximumSize = 2; + test('Image cache resizing based on count', () async { + imageCache.maximumSize = 2; - final TestImageInfo a = await extractOneFrame(const TestImageProvider(1, 1).resolve(ImageConfiguration.empty)); - final TestImageInfo b = await extractOneFrame(const TestImageProvider(2, 2).resolve(ImageConfiguration.empty)); - final TestImageInfo c = await extractOneFrame(const TestImageProvider(3, 3).resolve(ImageConfiguration.empty)); - final TestImageInfo d = await extractOneFrame(const TestImageProvider(1, 4).resolve(ImageConfiguration.empty)); - expect(a.value, equals(1)); - expect(b.value, equals(2)); - expect(c.value, equals(3)); - expect(d.value, equals(4)); + final TestImageInfo a = await extractOneFrame(const TestImageProvider(1, 1).resolve(ImageConfiguration.empty)); + final TestImageInfo b = await extractOneFrame(const TestImageProvider(2, 2).resolve(ImageConfiguration.empty)); + final TestImageInfo c = await extractOneFrame(const TestImageProvider(3, 3).resolve(ImageConfiguration.empty)); + final TestImageInfo d = await extractOneFrame(const TestImageProvider(1, 4).resolve(ImageConfiguration.empty)); + expect(a.value, equals(1)); + expect(b.value, equals(2)); + expect(c.value, equals(3)); + expect(d.value, equals(4)); - imageCache.maximumSize = 0; + imageCache.maximumSize = 0; - final TestImageInfo e = await extractOneFrame(const TestImageProvider(1, 5).resolve(ImageConfiguration.empty)); - expect(e.value, equals(5)); + final TestImageInfo e = await extractOneFrame(const TestImageProvider(1, 5).resolve(ImageConfiguration.empty)); + expect(e.value, equals(5)); - final TestImageInfo f = await extractOneFrame(const TestImageProvider(1, 6).resolve(ImageConfiguration.empty)); - expect(f.value, equals(6)); + final TestImageInfo f = await extractOneFrame(const TestImageProvider(1, 6).resolve(ImageConfiguration.empty)); + expect(f.value, equals(6)); - imageCache.maximumSize = 3; + imageCache.maximumSize = 3; - final TestImageInfo g = await extractOneFrame(const TestImageProvider(1, 7).resolve(ImageConfiguration.empty)); - expect(g.value, equals(7)); + final TestImageInfo g = await extractOneFrame(const TestImageProvider(1, 7).resolve(ImageConfiguration.empty)); + expect(g.value, equals(7)); - final TestImageInfo h = await extractOneFrame(const TestImageProvider(1, 8).resolve(ImageConfiguration.empty)); - expect(h.value, equals(7)); - }); + final TestImageInfo h = await extractOneFrame(const TestImageProvider(1, 8).resolve(ImageConfiguration.empty)); + expect(h.value, equals(7)); + }); - test('Image cache resizing based on size', () async { - const TestImage testImage = TestImage(width: 8, height: 8); // 256 B. - imageCache.maximumSizeBytes = 256 * 2; + test('Image cache resizing based on size', () async { + const TestImage testImage = TestImage(width: 8, height: 8); // 256 B. + imageCache.maximumSizeBytes = 256 * 2; - final TestImageInfo a = await extractOneFrame(const TestImageProvider(1, 1, image: testImage).resolve(ImageConfiguration.empty)); - final TestImageInfo b = await extractOneFrame(const TestImageProvider(2, 2, image: testImage).resolve(ImageConfiguration.empty)); - final TestImageInfo c = await extractOneFrame(const TestImageProvider(3, 3, image: testImage).resolve(ImageConfiguration.empty)); - final TestImageInfo d = await extractOneFrame(const TestImageProvider(1, 4, image: testImage).resolve(ImageConfiguration.empty)); - expect(a.value, equals(1)); - expect(b.value, equals(2)); - expect(c.value, equals(3)); - expect(d.value, equals(4)); + final TestImageInfo a = await extractOneFrame(const TestImageProvider(1, 1, image: testImage).resolve(ImageConfiguration.empty)); + final TestImageInfo b = await extractOneFrame(const TestImageProvider(2, 2, image: testImage).resolve(ImageConfiguration.empty)); + final TestImageInfo c = await extractOneFrame(const TestImageProvider(3, 3, image: testImage).resolve(ImageConfiguration.empty)); + final TestImageInfo d = await extractOneFrame(const TestImageProvider(1, 4, image: testImage).resolve(ImageConfiguration.empty)); + expect(a.value, equals(1)); + expect(b.value, equals(2)); + expect(c.value, equals(3)); + expect(d.value, equals(4)); - imageCache.maximumSizeBytes = 0; + imageCache.maximumSizeBytes = 0; - final TestImageInfo e = await extractOneFrame(const TestImageProvider(1, 5, image: testImage).resolve(ImageConfiguration.empty)); - expect(e.value, equals(5)); + final TestImageInfo e = await extractOneFrame(const TestImageProvider(1, 5, image: testImage).resolve(ImageConfiguration.empty)); + expect(e.value, equals(5)); - final TestImageInfo f = await extractOneFrame(const TestImageProvider(1, 6, image: testImage).resolve(ImageConfiguration.empty)); - expect(f.value, equals(6)); + final TestImageInfo f = await extractOneFrame(const TestImageProvider(1, 6, image: testImage).resolve(ImageConfiguration.empty)); + expect(f.value, equals(6)); - imageCache.maximumSizeBytes = 256 * 3; + imageCache.maximumSizeBytes = 256 * 3; - final TestImageInfo g = await extractOneFrame(const TestImageProvider(1, 7, image: testImage).resolve(ImageConfiguration.empty)); - expect(g.value, equals(7)); + final TestImageInfo g = await extractOneFrame(const TestImageProvider(1, 7, image: testImage).resolve(ImageConfiguration.empty)); + expect(g.value, equals(7)); - final TestImageInfo h = await extractOneFrame(const TestImageProvider(1, 8, image: testImage).resolve(ImageConfiguration.empty)); - expect(h.value, equals(7)); - }); + final TestImageInfo h = await extractOneFrame(const TestImageProvider(1, 8, image: testImage).resolve(ImageConfiguration.empty)); + expect(h.value, equals(7)); + }); }); } diff --git a/packages/flutter/test/painting/image_resolution_test.dart b/packages/flutter/test/painting/image_resolution_test.dart index 606e473ca1..7208645916 100644 --- a/packages/flutter/test/painting/image_resolution_test.dart +++ b/packages/flutter/test/painting/image_resolution_test.dart @@ -50,53 +50,35 @@ void main() { const ImageConfiguration configuration = ImageConfiguration(); assetImage.obtainKey(configuration) - .then(expectAsync1((AssetBundleImageKey bundleKey) { - expect(bundleKey.name, mainAssetPath); - expect(bundleKey.scale, 1.0); - })); + .then(expectAsync1((AssetBundleImageKey bundleKey) { + expect(bundleKey.name, mainAssetPath); + expect(bundleKey.scale, 1.0); + })); } test('When asset is main variant check scale is 1.0', () { _buildAndTestWithOneAsset('assets/normalFolder/normalFile.png'); }); + test('When asset path and key are the same string even though it could be took as a 3.0x variant', () async { + _buildAndTestWithOneAsset('assets/parentFolder/3.0x/normalFile.png'); + }); - test( - 'When asset path and key are the same string even though it could be took as a 3.0x variant', - () async { - _buildAndTestWithOneAsset('assets/parentFolder/3.0x/normalFile.png'); - }); + test('When asset path contains variant identifier as part of parent folder name scale is 1.0', () { + _buildAndTestWithOneAsset('assets/parentFolder/__3.0x__/leafFolder/normalFile.png'); + }); + test('When asset path contains variant identifier as part of leaf folder name scale is 1.0', () { + _buildAndTestWithOneAsset('assets/parentFolder/__3.0x_leaf_folder_/normalFile.png'); + }); - test( - 'When asset path contains variant identifier as part of parent folder name scale is 1.0', - () { - _buildAndTestWithOneAsset( - 'assets/parentFolder/__3.0x__/leafFolder/normalFile.png'); - }); + test('When asset path contains variant identifier as part of parent folder name scale is 1.0', () { + _buildAndTestWithOneAsset('assets/parentFolder/__3.0x__/leafFolder/normalFile.png'); + }); - - test( - 'When asset path contains variant identifier as part of leaf folder name scale is 1.0', - () { - _buildAndTestWithOneAsset( - 'assets/parentFolder/__3.0x_leaf_folder_/normalFile.png'); - }); - - - test( - 'When asset path contains variant identifier as part of parent folder name scale is 1.0', - () { - _buildAndTestWithOneAsset( - 'assets/parentFolder/__3.0x__/leafFolder/normalFile.png'); - }); - - test( - 'When asset path contains variant identifier in parent folder scale is 1.0', - () { - _buildAndTestWithOneAsset( - 'assets/parentFolder/3.0x/leafFolder/normalFile.png'); - }); + test('When asset path contains variant identifier in parent folder scale is 1.0', () { + _buildAndTestWithOneAsset('assets/parentFolder/3.0x/leafFolder/normalFile.png'); + }); }); @@ -119,16 +101,16 @@ void main() { // we have the exact match for this scale, let's use it assetImage.obtainKey(const ImageConfiguration()) - .then(expectAsync1((AssetBundleImageKey bundleKey) { - expect(bundleKey.name, mainAssetPath); - expect(bundleKey.scale, 1.0); - })); + .then(expectAsync1((AssetBundleImageKey bundleKey) { + expect(bundleKey.name, mainAssetPath); + expect(bundleKey.scale, 1.0); + })); // we also have the exact match for this scale, let's use it assetImage.obtainKey(ImageConfiguration( - bundle: testAssetBundle, - devicePixelRatio: 3.0)) - .then(expectAsync1((AssetBundleImageKey bundleKey) { + bundle: testAssetBundle, + devicePixelRatio: 3.0, + )).then(expectAsync1((AssetBundleImageKey bundleKey) { expect(bundleKey.name, variantPath); expect(bundleKey.scale, 3.0); })); @@ -152,15 +134,15 @@ void main() { assetImage.obtainKey(const ImageConfiguration()) - .then(expectAsync1((AssetBundleImageKey bundleKey) { - expect(bundleKey.name, mainAssetPath); - expect(bundleKey.scale, 1.0); - })); + .then(expectAsync1((AssetBundleImageKey bundleKey) { + expect(bundleKey.name, mainAssetPath); + expect(bundleKey.scale, 1.0); + })); assetImage.obtainKey(ImageConfiguration( - bundle: testAssetBundle, - devicePixelRatio: 3.0)) - .then(expectAsync1((AssetBundleImageKey bundleKey) { + bundle: testAssetBundle, + devicePixelRatio: 3.0) + ).then(expectAsync1((AssetBundleImageKey bundleKey) { expect(bundleKey.name, mainAssetPath); expect(bundleKey.scale, 1.0); })); @@ -191,9 +173,9 @@ void main() { // we have 1.0 and 3.0, asking for 1.5 should give assetImage.obtainKey(ImageConfiguration( - bundle: testAssetBundle, - devicePixelRatio: deviceRatio)) - .then(expectAsync1((AssetBundleImageKey bundleKey) { + bundle: testAssetBundle, + devicePixelRatio: deviceRatio) + ).then(expectAsync1((AssetBundleImageKey bundleKey) { expect(bundleKey.name, expectedAssetPath); expect(bundleKey.scale, chosenAssetRatio); })); diff --git a/packages/flutter/test/painting/image_stream_test.dart b/packages/flutter/test/painting/image_stream_test.dart index e78334f8ca..ab20df0710 100644 --- a/packages/flutter/test/painting/image_stream_test.dart +++ b/packages/flutter/test/painting/image_stream_test.dart @@ -104,27 +104,27 @@ void main() { }); testWidgets('getNextFrame future fails', (WidgetTester tester) async { - final MockCodec mockCodec = MockCodec(); - mockCodec.frameCount = 1; - final Completer codecCompleter = Completer(); + final MockCodec mockCodec = MockCodec(); + mockCodec.frameCount = 1; + final Completer codecCompleter = Completer(); - MultiFrameImageStreamCompleter( - codec: codecCompleter.future, - scale: 1.0, - ); + MultiFrameImageStreamCompleter( + codec: codecCompleter.future, + scale: 1.0, + ); - codecCompleter.complete(mockCodec); - // MultiFrameImageStreamCompleter only sets an error handler for the next - // frame future after the codec future has completed. - // Idling here lets the MultiFrameImageStreamCompleter advance and set the - // error handler for the nextFrame future. - await tester.idle(); + codecCompleter.complete(mockCodec); + // MultiFrameImageStreamCompleter only sets an error handler for the next + // frame future after the codec future has completed. + // Idling here lets the MultiFrameImageStreamCompleter advance and set the + // error handler for the nextFrame future. + await tester.idle(); - mockCodec.failNextFrame('frame completion error'); - await tester.idle(); + mockCodec.failNextFrame('frame completion error'); + await tester.idle(); - expect(tester.takeException(), 'frame completion error'); - }); + expect(tester.takeException(), 'frame completion error'); + }); testWidgets('ImageStream emits frame (static image)', (WidgetTester tester) async { final MockCodec mockCodec = MockCodec(); diff --git a/packages/flutter/test/semantics/traversal_order_test.dart b/packages/flutter/test/semantics/traversal_order_test.dart index 18712d5dd0..609417cee1 100644 --- a/packages/flutter/test/semantics/traversal_order_test.dart +++ b/packages/flutter/test/semantics/traversal_order_test.dart @@ -15,18 +15,21 @@ void main() { MaterialApp( home: Column( children: List.generate(3, (int column) { - return Row(children: List.generate(3, (int row) { - return Semantics( - child: SizedBox( - width: 50.0, - height: 50.0, - child: Text('$column - $row'), - ), - ); - })); - }), + return Row( + children: List.generate(3, (int row) { + return Semantics( + child: SizedBox( + width: 50.0, + height: 50.0, + child: Text('$column - $row'), + ), + ); + }), + ); + }), + ), ), - )); + ); final TestSemantics expected = TestSemantics.root( children: [ diff --git a/packages/flutter/test/services/fake_platform_views.dart b/packages/flutter/test/services/fake_platform_views.dart index 735db57dc0..6942d64fab 100644 --- a/packages/flutter/test/services/fake_platform_views.dart +++ b/packages/flutter/test/services/fake_platform_views.dart @@ -223,7 +223,7 @@ class FakeIosPlatformViewsController { final int id = args['id']; gesturesRejected[id] += 1; return Future.sync(() => null); - } + } Future _dispose(MethodCall call) { final int id = call.arguments; diff --git a/packages/flutter/test/services/platform_views_test.dart b/packages/flutter/test/services/platform_views_test.dart index e7e0336818..67fa4006a4 100644 --- a/packages/flutter/test/services/platform_views_test.dart +++ b/packages/flutter/test/services/platform_views_test.dart @@ -156,7 +156,7 @@ void main() { test('create iOS view of unregistered type', () async { expect( - () { + () { return PlatformViewsService.initUiKitView( id: 0, viewType: 'web', diff --git a/packages/flutter/test/services/text_input_test.dart b/packages/flutter/test/services/text_input_test.dart index 8f1da8198e..60984c91d4 100644 --- a/packages/flutter/test/services/text_input_test.dart +++ b/packages/flutter/test/services/text_input_test.dart @@ -80,6 +80,6 @@ void main() { expect(signed.hashCode == decimal.hashCode, false); expect(signed.hashCode == signedDecimal.hashCode, false); expect(decimal.hashCode == signedDecimal.hashCode, false); - }); + }); }); } diff --git a/packages/flutter/test/widgets/animated_list_test.dart b/packages/flutter/test/widgets/animated_list_test.dart index 2e9c31eb9e..47ab0322de 100644 --- a/packages/flutter/test/widgets/animated_list_test.dart +++ b/packages/flutter/test/widgets/animated_list_test.dart @@ -179,5 +179,5 @@ void main() { expect(itemBottom(1), 100.0); expect(itemTop(2), 100.0); expect(itemBottom(2), 200.0); - }); + }); } diff --git a/packages/flutter/test/widgets/annotated_region_test.dart b/packages/flutter/test/widgets/annotated_region_test.dart index 066e1cab75..45cd5c3fd1 100644 --- a/packages/flutter/test/widgets/annotated_region_test.dart +++ b/packages/flutter/test/widgets/annotated_region_test.dart @@ -9,8 +9,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - testWidgets('provides a value to the layer tree', - (WidgetTester tester) async { + testWidgets('provides a value to the layer tree', (WidgetTester tester) async { await tester.pumpWidget( const AnnotatedRegion( child: SizedBox(width: 100.0, height: 100.0), @@ -22,8 +21,7 @@ void main() { layers.firstWhere((Layer layer) => layer is AnnotatedRegionLayer); expect(layer.value, 1); }); - testWidgets('provides a value to the layer tree in a particular region', - (WidgetTester tester) async { + testWidgets('provides a value to the layer tree in a particular region', (WidgetTester tester) async { await tester.pumpWidget( Transform.translate( offset: const Offset(25.0, 25.0), diff --git a/packages/flutter/test/widgets/custom_single_child_layout_test.dart b/packages/flutter/test/widgets/custom_single_child_layout_test.dart index 3f9e9978f4..403602797c 100644 --- a/packages/flutter/test/widgets/custom_single_child_layout_test.dart +++ b/packages/flutter/test/widgets/custom_single_child_layout_test.dart @@ -94,10 +94,8 @@ Widget buildFrame(SingleChildLayoutDelegate delegate) { } void main() { - testWidgets('Control test for CustomSingleChildLayout', - (WidgetTester tester) async { - final TestSingleChildLayoutDelegate delegate = - TestSingleChildLayoutDelegate(); + testWidgets('Control test for CustomSingleChildLayout', (WidgetTester tester) async { + final TestSingleChildLayoutDelegate delegate = TestSingleChildLayoutDelegate(); await tester.pumpWidget(buildFrame(delegate)); expect(delegate.constraintsFromGetSize.minWidth, 0.0); @@ -117,8 +115,7 @@ void main() { expect(delegate.childSizeFromGetPositionForChild.height, 400.0); }); - testWidgets('Test SingleChildDelegate shouldRelayout method', - (WidgetTester tester) async { + testWidgets('Test SingleChildDelegate shouldRelayout method', (WidgetTester tester) async { TestSingleChildLayoutDelegate delegate = TestSingleChildLayoutDelegate(); await tester.pumpWidget(buildFrame(delegate)); diff --git a/packages/flutter/test/widgets/draggable_test.dart b/packages/flutter/test/widgets/draggable_test.dart index 54bc5c5dc6..e785f4e073 100644 --- a/packages/flutter/test/widgets/draggable_test.dart +++ b/packages/flutter/test/widgets/draggable_test.dart @@ -137,7 +137,7 @@ void main() { expect(leftBehind['Target 1'], equals(1)); expect(leftBehind['Target 2'], equals(1)); - }); + }); testWidgets('Drag and drop - dragging over button', (WidgetTester tester) async { final List events = []; @@ -685,7 +685,7 @@ void main() { expect(tester.getTopLeft(find.text('H')), thirdWidgetLocation); }); - testWidgets('Vertical axis draggable moves vertically', (WidgetTester tester) async { + testWidgets('Vertical axis draggable moves vertically', (WidgetTester tester) async { await tester.pumpWidget(build()); final Offset firstLocation = tester.getTopLeft(find.text('V')); final Offset secondLocation = firstLocation + const Offset(0.0, 300.0); diff --git a/packages/flutter/test/widgets/editable_text_cursor_test.dart b/packages/flutter/test/widgets/editable_text_cursor_test.dart index 53754dbfa4..6e00f92633 100644 --- a/packages/flutter/test/widgets/editable_text_cursor_test.dart +++ b/packages/flutter/test/widgets/editable_text_cursor_test.dart @@ -242,9 +242,7 @@ void main() { expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0)); }); - testWidgets( - 'Cursor does not animates on iOS when debugDeterministicCursor is set', - (WidgetTester tester) async { + testWidgets('Cursor does not animates on iOS when debugDeterministicCursor is set', (WidgetTester tester) async { EditableText.debugDeterministicCursor = true; final Widget widget = MaterialApp( theme: ThemeData(platform: TargetPlatform.iOS), @@ -282,9 +280,7 @@ void main() { EditableText.debugDeterministicCursor = false; }); - testWidgets( - 'Cursor does not animate on Android when debugDeterministicCursor is set', - (WidgetTester tester) async { + testWidgets('Cursor does not animate on Android when debugDeterministicCursor is set', (WidgetTester tester) async { EditableText.debugDeterministicCursor = true; const Widget widget = MaterialApp( diff --git a/packages/flutter/test/widgets/editable_text_test.dart b/packages/flutter/test/widgets/editable_text_test.dart index ade64bd06e..5544ad8dc6 100644 --- a/packages/flutter/test/widgets/editable_text_test.dart +++ b/packages/flutter/test/widgets/editable_text_test.dart @@ -92,8 +92,7 @@ void main() { expect(editableText.cursorWidth, 2.0); }); - testWidgets('text keyboard is requested when maxLines is default', - (WidgetTester tester) async { + testWidgets('text keyboard is requested when maxLines is default', (WidgetTester tester) async { await tester.pumpWidget( MediaQuery( data: const MediaQueryData(devicePixelRatio: 1.0), @@ -127,9 +126,7 @@ void main() { equals('TextInputAction.done')); }); - testWidgets( - 'Keyboard is configured for "unspecified" action when explicitly requested', - (WidgetTester tester) async { + testWidgets('Keyboard is configured for "unspecified" action when explicitly requested', (WidgetTester tester) async { await _desiredKeyboardActionIsRequested( tester: tester, action: TextInputAction.unspecified, @@ -137,9 +134,7 @@ void main() { ); }); - testWidgets( - 'Keyboard is configured for "none" action when explicitly requested', - (WidgetTester tester) async { + testWidgets('Keyboard is configured for "none" action when explicitly requested', (WidgetTester tester) async { await _desiredKeyboardActionIsRequested( tester: tester, action: TextInputAction.none, @@ -147,9 +142,7 @@ void main() { ); }); - testWidgets( - 'Keyboard is configured for "done" action when explicitly requested', - (WidgetTester tester) async { + testWidgets('Keyboard is configured for "done" action when explicitly requested', (WidgetTester tester) async { await _desiredKeyboardActionIsRequested( tester: tester, action: TextInputAction.done, @@ -157,9 +150,7 @@ void main() { ); }); - testWidgets( - 'Keyboard is configured for "send" action when explicitly requested', - (WidgetTester tester) async { + testWidgets('Keyboard is configured for "send" action when explicitly requested', (WidgetTester tester) async { await _desiredKeyboardActionIsRequested( tester: tester, action: TextInputAction.send, @@ -167,9 +158,7 @@ void main() { ); }); - testWidgets( - 'Keyboard is configured for "go" action when explicitly requested', - (WidgetTester tester) async { + testWidgets('Keyboard is configured for "go" action when explicitly requested', (WidgetTester tester) async { await _desiredKeyboardActionIsRequested( tester: tester, action: TextInputAction.go, @@ -177,9 +166,7 @@ void main() { ); }); - testWidgets( - 'Keyboard is configured for "search" action when explicitly requested', - (WidgetTester tester) async { + testWidgets('Keyboard is configured for "search" action when explicitly requested', (WidgetTester tester) async { await _desiredKeyboardActionIsRequested( tester: tester, action: TextInputAction.search, @@ -187,9 +174,7 @@ void main() { ); }); - testWidgets( - 'Keyboard is configured for "send" action when explicitly requested', - (WidgetTester tester) async { + testWidgets('Keyboard is configured for "send" action when explicitly requested', (WidgetTester tester) async { await _desiredKeyboardActionIsRequested( tester: tester, action: TextInputAction.send, @@ -197,9 +182,7 @@ void main() { ); }); - testWidgets( - 'Keyboard is configured for "next" action when explicitly requested', - (WidgetTester tester) async { + testWidgets('Keyboard is configured for "next" action when explicitly requested', (WidgetTester tester) async { await _desiredKeyboardActionIsRequested( tester: tester, action: TextInputAction.next, @@ -207,9 +190,7 @@ void main() { ); }); - testWidgets( - 'Keyboard is configured for "previous" action when explicitly requested', - (WidgetTester tester) async { + testWidgets('Keyboard is configured for "previous" action when explicitly requested', (WidgetTester tester) async { await _desiredKeyboardActionIsRequested( tester: tester, action: TextInputAction.previous, @@ -217,9 +198,7 @@ void main() { ); }); - testWidgets( - 'Keyboard is configured for "continue" action when explicitly requested', - (WidgetTester tester) async { + testWidgets('Keyboard is configured for "continue" action when explicitly requested', (WidgetTester tester) async { await _desiredKeyboardActionIsRequested( tester: tester, action: TextInputAction.continueAction, @@ -227,9 +206,7 @@ void main() { ); }); - testWidgets( - 'Keyboard is configured for "join" action when explicitly requested', - (WidgetTester tester) async { + testWidgets('Keyboard is configured for "join" action when explicitly requested', (WidgetTester tester) async { await _desiredKeyboardActionIsRequested( tester: tester, action: TextInputAction.join, @@ -237,9 +214,7 @@ void main() { ); }); - testWidgets( - 'Keyboard is configured for "route" action when explicitly requested', - (WidgetTester tester) async { + testWidgets('Keyboard is configured for "route" action when explicitly requested', (WidgetTester tester) async { await _desiredKeyboardActionIsRequested( tester: tester, action: TextInputAction.route, @@ -247,9 +222,7 @@ void main() { ); }); - testWidgets( - 'Keyboard is configured for "emergencyCall" action when explicitly requested', - (WidgetTester tester) async { + testWidgets('Keyboard is configured for "emergencyCall" action when explicitly requested', (WidgetTester tester) async { await _desiredKeyboardActionIsRequested( tester: tester, action: TextInputAction.emergencyCall, @@ -257,8 +230,7 @@ void main() { ); }); - testWidgets('multiline keyboard is requested when set explicitly', - (WidgetTester tester) async { + testWidgets('multiline keyboard is requested when set explicitly', (WidgetTester tester) async { await tester.pumpWidget( MediaQuery( data: const MediaQueryData(devicePixelRatio: 1.0), @@ -358,9 +330,7 @@ void main() { equals('TextInputAction.done')); }); - testWidgets( - 'Correct keyboard is requested when set explicitly and maxLines > 1', - (WidgetTester tester) async { + testWidgets('Correct keyboard is requested when set explicitly and maxLines > 1', (WidgetTester tester) async { await tester.pumpWidget( MediaQuery( data: const MediaQueryData(devicePixelRatio: 1.0), @@ -394,8 +364,7 @@ void main() { equals('TextInputAction.done')); }); - testWidgets('multiline keyboard is requested when set implicitly', - (WidgetTester tester) async { + testWidgets('multiline keyboard is requested when set implicitly', (WidgetTester tester) async { await tester.pumpWidget( MediaQuery( data: const MediaQueryData(devicePixelRatio: 1.0), @@ -428,8 +397,7 @@ void main() { equals('TextInputAction.newline')); }); - testWidgets('single line inputs have correct default keyboard', - (WidgetTester tester) async { + testWidgets('single line inputs have correct default keyboard', (WidgetTester tester) async { await tester.pumpWidget( MediaQuery( data: const MediaQueryData(devicePixelRatio: 1.0), @@ -462,8 +430,7 @@ void main() { equals('TextInputAction.done')); }); - testWidgets('can only show toolbar when there is text and a selection', - (WidgetTester tester) async { + testWidgets('can only show toolbar when there is text and a selection', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: EditableText( @@ -501,8 +468,7 @@ void main() { expect(find.text('PASTE'), findsOneWidget); }); - testWidgets('Fires onChanged when text changes via TextSelectionOverlay', - (WidgetTester tester) async { + testWidgets('Fires onChanged when text changes via TextSelectionOverlay', (WidgetTester tester) async { final GlobalKey editableTextKey = GlobalKey(); @@ -527,11 +493,11 @@ void main() { // Populate a fake clipboard. const String clipboardContent = 'Dobunezumi mitai ni utsukushiku naritai'; SystemChannels.platform - .setMockMethodCallHandler((MethodCall methodCall) async { - if (methodCall.method == 'Clipboard.getData') - return const {'text': clipboardContent}; - return null; - }); + .setMockMethodCallHandler((MethodCall methodCall) async { + if (methodCall.method == 'Clipboard.getData') + return const {'text': clipboardContent}; + return null; + }); // Long-press to bring up the text editing controls. final Finder textFinder = find.byKey(editableTextKey); @@ -545,8 +511,7 @@ void main() { expect(changedValue, clipboardContent); }); - testWidgets('Does not lose focus by default when "next" action is pressed', - (WidgetTester tester) async { + testWidgets('Does not lose focus by default when "next" action is pressed', (WidgetTester tester) async { final GlobalKey editableTextKey = GlobalKey(); final FocusNode focusNode = FocusNode(); @@ -579,9 +544,7 @@ void main() { expect(focusNode.hasFocus, true); }); - testWidgets( - 'Does not lose focus by default when "done" action is pressed and onEditingComplete is provided', - (WidgetTester tester) async { + testWidgets('Does not lose focus by default when "done" action is pressed and onEditingComplete is provided', (WidgetTester tester) async { final GlobalKey editableTextKey = GlobalKey(); final FocusNode focusNode = FocusNode(); @@ -618,9 +581,7 @@ void main() { expect(focusNode.hasFocus, true); }); - testWidgets( - 'When "done" is pressed callbacks are invoked: onEditingComplete > onSubmitted', - (WidgetTester tester) async { + testWidgets('When "done" is pressed callbacks are invoked: onEditingComplete > onSubmitted', (WidgetTester tester) async { final GlobalKey editableTextKey = GlobalKey(); final FocusNode focusNode = FocusNode(); @@ -663,9 +624,7 @@ void main() { // and onSubmission callbacks. }); - testWidgets( - 'When "next" is pressed callbacks are invoked: onEditingComplete > onSubmitted', - (WidgetTester tester) async { + testWidgets('When "next" is pressed callbacks are invoked: onEditingComplete > onSubmitted', (WidgetTester tester) async { final GlobalKey editableTextKey = GlobalKey(); final FocusNode focusNode = FocusNode(); @@ -708,9 +667,7 @@ void main() { // and onSubmission callbacks. }); - testWidgets( - 'When "newline" action is called on a Editable text with maxLines == 1 callbacks are invoked: onEditingComplete > onSubmitted', - (WidgetTester tester) async { + testWidgets('When "newline" action is called on a Editable text with maxLines == 1 callbacks are invoked: onEditingComplete > onSubmitted', (WidgetTester tester) async { final GlobalKey editableTextKey = GlobalKey(); final FocusNode focusNode = FocusNode(); @@ -753,9 +710,7 @@ void main() { // and onSubmission callbacks. }); - testWidgets( - 'When "newline" action is called on a Editable text with maxLines != 1, onEditingComplete and onSubmitted callbacks are not invoked.', - (WidgetTester tester) async { + testWidgets('When "newline" action is called on a Editable text with maxLines != 1, onEditingComplete and onSubmitted callbacks are not invoked.', (WidgetTester tester) async { final GlobalKey editableTextKey = GlobalKey(); final FocusNode focusNode = FocusNode(); @@ -798,8 +753,7 @@ void main() { assert(!onEditingCompleteCalled); }); - testWidgets('Changing controller updates EditableText', - (WidgetTester tester) async { + testWidgets('Changing controller updates EditableText', (WidgetTester tester) async { final GlobalKey editableTextKey = GlobalKey(); final TextEditingController controller1 = @@ -871,8 +825,7 @@ void main() { ); }); - testWidgets('EditableText identifies as text field (w/ focus) in semantics', - (WidgetTester tester) async { + testWidgets('EditableText identifies as text field (w/ focus) in semantics', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( @@ -912,8 +865,7 @@ void main() { semantics.dispose(); }); - testWidgets('EditableText includes text as value in semantics', - (WidgetTester tester) async { + testWidgets('EditableText includes text as value in semantics', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); const String value1 = 'EditableText content'; @@ -1008,8 +960,7 @@ void main() { ); }); - testWidgets('exposes correct cursor movement semantics', - (WidgetTester tester) async { + testWidgets('exposes correct cursor movement semantics', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); controller.text = 'test'; @@ -1280,8 +1231,7 @@ void main() { semantics.dispose(); }); - testWidgets('can extend selection with a11y means - character', - (WidgetTester tester) async { + testWidgets('can extend selection with a11y means - character', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); const bool extendSelection = true; const bool doNotExtendSelection = false; @@ -1382,111 +1332,109 @@ void main() { semantics.dispose(); }); - testWidgets('can extend selection with a11y means - word', - (WidgetTester tester) async { - final SemanticsTester semantics = SemanticsTester(tester); - const bool extendSelection = true; - const bool doNotExtendSelection = false; + testWidgets('can extend selection with a11y means - word', (WidgetTester tester) async { + final SemanticsTester semantics = SemanticsTester(tester); + const bool extendSelection = true; + const bool doNotExtendSelection = false; - controller.text = 'test for words'; - controller.selection = - TextSelection.collapsed(offset: controller.text.length); + controller.text = 'test for words'; + controller.selection = + TextSelection.collapsed(offset: controller.text.length); - await tester.pumpWidget(MaterialApp( - home: EditableText( - backgroundCursorColor: Colors.grey, - controller: controller, - focusNode: focusNode, - style: textStyle, - cursorColor: cursorColor, - ), - )); + await tester.pumpWidget(MaterialApp( + home: EditableText( + backgroundCursorColor: Colors.grey, + controller: controller, + focusNode: focusNode, + style: textStyle, + cursorColor: cursorColor, + ), + )); - expect( - semantics, - includesNodeWith( - value: 'test for words', - actions: [ - SemanticsAction.moveCursorBackwardByCharacter, - SemanticsAction.moveCursorBackwardByWord, - ], - ), - ); + expect( + semantics, + includesNodeWith( + value: 'test for words', + actions: [ + SemanticsAction.moveCursorBackwardByCharacter, + SemanticsAction.moveCursorBackwardByWord, + ], + ), + ); - final RenderEditable render = tester.allRenderObjects - .firstWhere((RenderObject o) => o.runtimeType == RenderEditable); - final int semanticsId = render.debugSemantics.id; + final RenderEditable render = tester.allRenderObjects + .firstWhere((RenderObject o) => o.runtimeType == RenderEditable); + final int semanticsId = render.debugSemantics.id; - expect(controller.selection.baseOffset, 14); - expect(controller.selection.extentOffset, 14); + expect(controller.selection.baseOffset, 14); + expect(controller.selection.extentOffset, 14); - tester.binding.pipelineOwner.semanticsOwner.performAction(semanticsId, - SemanticsAction.moveCursorBackwardByWord, extendSelection); - await tester.pumpAndSettle(); + tester.binding.pipelineOwner.semanticsOwner.performAction(semanticsId, + SemanticsAction.moveCursorBackwardByWord, extendSelection); + await tester.pumpAndSettle(); - expect(controller.selection.baseOffset, 14); - expect(controller.selection.extentOffset, 9); + expect(controller.selection.baseOffset, 14); + expect(controller.selection.extentOffset, 9); - expect( - semantics, - includesNodeWith( - value: 'test for words', - actions: [ - SemanticsAction.moveCursorBackwardByCharacter, - SemanticsAction.moveCursorForwardByCharacter, - SemanticsAction.moveCursorBackwardByWord, - SemanticsAction.moveCursorForwardByWord, - SemanticsAction.setSelection, - ], - ), - ); + expect( + semantics, + includesNodeWith( + value: 'test for words', + actions: [ + SemanticsAction.moveCursorBackwardByCharacter, + SemanticsAction.moveCursorForwardByCharacter, + SemanticsAction.moveCursorBackwardByWord, + SemanticsAction.moveCursorForwardByWord, + SemanticsAction.setSelection, + ], + ), + ); - tester.binding.pipelineOwner.semanticsOwner.performAction(semanticsId, - SemanticsAction.moveCursorBackwardByWord, extendSelection); - await tester.pumpAndSettle(); + tester.binding.pipelineOwner.semanticsOwner.performAction(semanticsId, + SemanticsAction.moveCursorBackwardByWord, extendSelection); + await tester.pumpAndSettle(); - expect(controller.selection.baseOffset, 14); - expect(controller.selection.extentOffset, 5); + expect(controller.selection.baseOffset, 14); + expect(controller.selection.extentOffset, 5); - tester.binding.pipelineOwner.semanticsOwner.performAction(semanticsId, - SemanticsAction.moveCursorBackwardByWord, extendSelection); - await tester.pumpAndSettle(); + tester.binding.pipelineOwner.semanticsOwner.performAction(semanticsId, + SemanticsAction.moveCursorBackwardByWord, extendSelection); + await tester.pumpAndSettle(); - expect(controller.selection.baseOffset, 14); - expect(controller.selection.extentOffset, 0); + expect(controller.selection.baseOffset, 14); + expect(controller.selection.extentOffset, 0); - await tester.pumpAndSettle(); - expect( - semantics, - includesNodeWith( - value: 'test for words', - actions: [ - SemanticsAction.moveCursorForwardByCharacter, - SemanticsAction.moveCursorForwardByWord, - SemanticsAction.setSelection, - ], - ), - ); + await tester.pumpAndSettle(); + expect( + semantics, + includesNodeWith( + value: 'test for words', + actions: [ + SemanticsAction.moveCursorForwardByCharacter, + SemanticsAction.moveCursorForwardByWord, + SemanticsAction.setSelection, + ], + ), + ); - tester.binding.pipelineOwner.semanticsOwner.performAction(semanticsId, - SemanticsAction.moveCursorForwardByWord, doNotExtendSelection); - await tester.pumpAndSettle(); + tester.binding.pipelineOwner.semanticsOwner.performAction(semanticsId, + SemanticsAction.moveCursorForwardByWord, doNotExtendSelection); + await tester.pumpAndSettle(); - expect(controller.selection.baseOffset, 5); - expect(controller.selection.extentOffset, 5); + expect(controller.selection.baseOffset, 5); + expect(controller.selection.extentOffset, 5); - tester.binding.pipelineOwner.semanticsOwner.performAction(semanticsId, - SemanticsAction.moveCursorForwardByWord, extendSelection); - await tester.pumpAndSettle(); + tester.binding.pipelineOwner.semanticsOwner.performAction(semanticsId, + SemanticsAction.moveCursorForwardByWord, extendSelection); + await tester.pumpAndSettle(); - expect(controller.selection.baseOffset, 5); - expect(controller.selection.extentOffset, 9); + expect(controller.selection.baseOffset, 5); + expect(controller.selection.extentOffset, 9); - semantics.dispose(); + semantics.dispose(); }); - testWidgets('password fields have correct semantics', - (WidgetTester tester) async { + testWidgets('password fields have correct semantics', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); controller.text = 'super-secret-password!!1'; @@ -1537,8 +1485,7 @@ void main() { semantics.dispose(); }); - testWidgets('password fields become obscured with the right semantics when set', - (WidgetTester tester) async { + testWidgets('password fields become obscured with the right semantics when set', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); const String originalText = 'super-secret-password!!1'; @@ -1820,8 +1767,7 @@ void main() { }); }); - testWidgets('allows customizing text style in subclasses', - (WidgetTester tester) async { + testWidgets('allows customizing text style in subclasses', (WidgetTester tester) async { controller.text = 'Hello World'; await tester.pumpWidget(MaterialApp( @@ -1950,9 +1896,7 @@ void main() { expect(setClient.arguments.last['keyboardAppearance'], 'Brightness.dark'); }); - testWidgets( - 'Composing text is underlined and underline is cleared when losing focus', - (WidgetTester tester) async { + testWidgets('Composing text is underlined and underline is cleared when losing focus', (WidgetTester tester) async { final TextEditingController controller = TextEditingController.fromValue( const TextEditingValue( text: 'text composing text', diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index 403d1399e0..28268dc030 100644 --- a/packages/flutter/test/widgets/heroes_test.dart +++ b/packages/flutter/test/widgets/heroes_test.dart @@ -95,24 +95,26 @@ final Map routes = { }; class ThreeRoute extends MaterialPageRoute { - ThreeRoute() : super(builder: (BuildContext context) { - return Material( - key: routeThreeKey, - child: ListView( - children: [ - Container(height: 200.0, width: 200.0), - Card(child: Hero(tag: 'a', child: Container(height: 200.0, width: 200.0, key: thirdKey))), - Container(height: 200.0, width: 200.0), - ], - ), - ); - }); + ThreeRoute() + : super(builder: (BuildContext context) { + return Material( + key: routeThreeKey, + child: ListView( + children: [ + Container(height: 200.0, width: 200.0), + Card(child: Hero(tag: 'a', child: Container(height: 200.0, width: 200.0, key: thirdKey))), + Container(height: 200.0, width: 200.0), + ], + ), + ); + }); } class MutatingRoute extends MaterialPageRoute { - MutatingRoute() : super(builder: (BuildContext context) { - return Hero(tag: 'a', child: const Text('MutatingRoute'), key: UniqueKey()); - }); + MutatingRoute() + : super(builder: (BuildContext context) { + return Hero(tag: 'a', child: const Text('MutatingRoute'), key: UniqueKey()); + }); void markNeedsBuild() { setState(() { diff --git a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart index cc6a937bad..d92dddaa09 100644 --- a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart +++ b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart @@ -55,7 +55,7 @@ void main() { testWidgets('ListWheelScrollView needs positive magnification', (WidgetTester tester) async { expect( - () { + () { ListWheelScrollView( useMagnifier: true, magnification: -1.0, diff --git a/packages/flutter/test/widgets/navigator_test.dart b/packages/flutter/test/widgets/navigator_test.dart index 54e38867ff..1e3c97bc24 100644 --- a/packages/flutter/test/widgets/navigator_test.dart +++ b/packages/flutter/test/widgets/navigator_test.dart @@ -360,8 +360,7 @@ void main() { expect(find.text('B'), findsOneWidget); }); - testWidgets('Push and pop should trigger the observers', - (WidgetTester tester) async { + testWidgets('Push and pop should trigger the observers', (WidgetTester tester) async { final Map routes = { '/': (BuildContext context) => OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }), '/A': (BuildContext context) => OnTapPage(id: 'A', onTap: () { Navigator.pop(context); }), @@ -723,8 +722,7 @@ void main() { expect(log, ['pushed / (previous is )', 'pushed B (previous is /)', 'pushed C (previous is B)', 'replaced B with D']); }); - testWidgets('didStartUserGesture observable', - (WidgetTester tester) async { + testWidgets('didStartUserGesture observable', (WidgetTester tester) async { final Map routes = { '/': (BuildContext context) => OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }), '/A': (BuildContext context) => OnTapPage(id: 'A', onTap: () { Navigator.pop(context); }), diff --git a/packages/flutter/test/widgets/overlay_test.dart b/packages/flutter/test/widgets/overlay_test.dart index c393c59eec..142d7f4fcd 100644 --- a/packages/flutter/test/widgets/overlay_test.dart +++ b/packages/flutter/test/widgets/overlay_test.dart @@ -6,8 +6,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; void main() { - testWidgets('OverflowEntries context contains Overlay', - (WidgetTester tester) async { + testWidgets('OverflowEntries context contains Overlay', (WidgetTester tester) async { final GlobalKey overlayKey = GlobalKey(); bool didBuild = false; await tester.pumpWidget( diff --git a/packages/flutter/test/widgets/page_view_test.dart b/packages/flutter/test/widgets/page_view_test.dart index 31961972c7..504e77fb08 100644 --- a/packages/flutter/test/widgets/page_view_test.dart +++ b/packages/flutter/test/widgets/page_view_test.dart @@ -81,8 +81,7 @@ void main() { expect(find.text('Arizona'), findsNothing); }); - testWidgets('PageView does not squish when overscrolled', - (WidgetTester tester) async { + testWidgets('PageView does not squish when overscrolled', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( theme: ThemeData(platform: TargetPlatform.iOS), home: PageView( @@ -566,8 +565,7 @@ void main() { expect(tester.getTopLeft(find.text('Hawaii')), const Offset(-100.0, 0.0)); }); - testWidgets('PageView does not report page changed on overscroll', - (WidgetTester tester) async { + testWidgets('PageView does not report page changed on overscroll', (WidgetTester tester) async { final PageController controller = PageController( initialPage: kStates.length - 1, ); @@ -594,8 +592,7 @@ void main() { expect(changeIndex, 0); }); - testWidgets('PageView can restore page', - (WidgetTester tester) async { + testWidgets('PageView can restore page', (WidgetTester tester) async { final PageController controller = PageController(); try { controller.page; diff --git a/packages/flutter/test/widgets/raw_keyboard_listener_test.dart b/packages/flutter/test/widgets/raw_keyboard_listener_test.dart index dd02459a83..f368168e21 100644 --- a/packages/flutter/test/widgets/raw_keyboard_listener_test.dart +++ b/packages/flutter/test/widgets/raw_keyboard_listener_test.dart @@ -60,8 +60,7 @@ void main() { focusNode.dispose(); }); - testWidgets('Defunct listeners do not receive events', - (WidgetTester tester) async { + testWidgets('Defunct listeners do not receive events', (WidgetTester tester) async { final List events = []; final FocusNode focusNode = FocusNode(); diff --git a/packages/flutter/test/widgets/reparent_state_harder_test.dart b/packages/flutter/test/widgets/reparent_state_harder_test.dart index 8f48b304a6..64bf479e0f 100644 --- a/packages/flutter/test/widgets/reparent_state_harder_test.dart +++ b/packages/flutter/test/widgets/reparent_state_harder_test.dart @@ -156,8 +156,10 @@ void main() { keyRoot.currentState.switchChildren(); final List states = tester.stateList(find.byType(RekeyableDummyStatefulWidgetWrapper)).toList(); - final RekeyableDummyStatefulWidgetWrapperState a = states[0]; a._setChild(null); - final RekeyableDummyStatefulWidgetWrapperState b = states[1]; b._setChild(keyC); + final RekeyableDummyStatefulWidgetWrapperState a = states[0]; + a._setChild(null); + final RekeyableDummyStatefulWidgetWrapperState b = states[1]; + b._setChild(keyC); await tester.pump(); expect(find.byKey(keyA), findsOneWidget); diff --git a/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart b/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart index 8fef52227f..859ea4442b 100644 --- a/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart +++ b/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart @@ -66,8 +66,7 @@ class StatefulCreationCounterState extends State { } void main() { - testWidgets('reparent state with layout builder', - (WidgetTester tester) async { + testWidgets('reparent state with layout builder', (WidgetTester tester) async { expect(StatefulCreationCounterState.creationCount, 0); await tester.pumpWidget(Bar()); expect(StatefulCreationCounterState.creationCount, 1); @@ -77,9 +76,7 @@ void main() { expect(StatefulCreationCounterState.creationCount, 1); }); - testWidgets('Clean then reparent with dependencies', - (WidgetTester tester) async { - + testWidgets('Clean then reparent with dependencies', (WidgetTester tester) async { int layoutBuilderBuildCount = 0; StateSetter keyedSetState; @@ -103,8 +100,7 @@ void main() { data: MediaQueryData.fromWindow(ui.window), child: Column( children: [ - StatefulBuilder( - builder: (BuildContext context, StateSetter setState) { + StatefulBuilder(builder: (BuildContext context, StateSetter setState) { layoutBuilderSetState = setState; return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { @@ -119,11 +115,12 @@ void main() { child: Container( child: Container( child: Container( - child: StatefulBuilder(builder: - (BuildContext context, StateSetter setState) { - childSetState = setState; - return deepChild; // initially a Container, but then the keyedWidget above - }), + child: StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + childSetState = setState; + return deepChild; // initially a Container, but then the keyedWidget above + }, + ), ), ), ), diff --git a/packages/flutter/test/widgets/semantics_debugger_test.dart b/packages/flutter/test/widgets/semantics_debugger_test.dart index cf0e5359e2..42eacb91a3 100644 --- a/packages/flutter/test/widgets/semantics_debugger_test.dart +++ b/packages/flutter/test/widgets/semantics_debugger_test.dart @@ -54,8 +54,7 @@ void main() { expect(true, isTrue); // expect that we reach here without crashing }); - testWidgets('SemanticsDebugger reparents subtree', - (WidgetTester tester) async { + testWidgets('SemanticsDebugger reparents subtree', (WidgetTester tester) async { final GlobalKey key = GlobalKey(); await tester.pumpWidget( @@ -140,8 +139,7 @@ void main() { expect(tester.takeException(), isNull); }); - testWidgets('SemanticsDebugger interaction test', - (WidgetTester tester) async { + testWidgets('SemanticsDebugger interaction test', (WidgetTester tester) async { final List log = []; await tester.pumpWidget( @@ -179,8 +177,7 @@ void main() { log.clear(); }); - testWidgets('SemanticsDebugger interaction test - negative', - (WidgetTester tester) async { + testWidgets('SemanticsDebugger interaction test - negative', (WidgetTester tester) async { final List log = []; await tester.pumpWidget( diff --git a/packages/flutter/test/widgets/semantics_test.dart b/packages/flutter/test/widgets/semantics_test.dart index 018eab4917..64dc727023 100644 --- a/packages/flutter/test/widgets/semantics_test.dart +++ b/packages/flutter/test/widgets/semantics_test.dart @@ -967,9 +967,7 @@ void main() { semantics.dispose(); }); - testWidgets( - 'Semantics widgets without sort orders are sorted properly when no Directionality is present', - (WidgetTester tester) async { + testWidgets('Semantics widgets without sort orders are sorted properly when no Directionality is present', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); int semanticsUpdateCount = 0; final SemanticsHandle handle = tester.binding.pipelineOwner.ensureSemantics(listener: () { diff --git a/packages/flutter/test/widgets/set_state_5_test.dart b/packages/flutter/test/widgets/set_state_5_test.dart index fe4f60a454..dc51089fc4 100644 --- a/packages/flutter/test/widgets/set_state_5_test.dart +++ b/packages/flutter/test/widgets/set_state_5_test.dart @@ -14,7 +14,7 @@ class BadWidget extends StatefulWidget { class BadWidgetState extends State { BadWidgetState() { setState(() { - _count = 1; + _count = 1; }); } diff --git a/packages/flutter/test/widgets/sliver_list_test.dart b/packages/flutter/test/widgets/sliver_list_test.dart index 9db3c881ce..1434877aea 100644 --- a/packages/flutter/test/widgets/sliver_list_test.dart +++ b/packages/flutter/test/widgets/sliver_list_test.dart @@ -162,7 +162,7 @@ Widget _buildSliverList({ slivers: [ SliverList( delegate: SliverChildBuilderDelegate( - (BuildContext context, int i) { + (BuildContext context, int i) { return Container( key: ValueKey(items[i]), height: itemHeight, diff --git a/packages/flutter/test/widgets/text_selection_test.dart b/packages/flutter/test/widgets/text_selection_test.dart index 64d4d8c107..10f11882af 100644 --- a/packages/flutter/test/widgets/text_selection_test.dart +++ b/packages/flutter/test/widgets/text_selection_test.dart @@ -201,7 +201,7 @@ void main() { await gesture.up(); await tester.pump(const Duration(milliseconds: 20)); - await gesture.downWithCustomEvent( + await gesture.downWithCustomEvent( forcePressOffset, const PointerDownEvent( pointer: pointerValue, diff --git a/packages/flutter/test/widgets/title_test.dart b/packages/flutter/test/widgets/title_test.dart index 99b688bc9f..ec14df7a64 100644 --- a/packages/flutter/test/widgets/title_test.dart +++ b/packages/flutter/test/widgets/title_test.dart @@ -45,8 +45,7 @@ void main() { ), throwsAssertionError); }); - testWidgets('should not pass "null" to setApplicationSwitcherDescription', - (WidgetTester tester) async { + testWidgets('should not pass "null" to setApplicationSwitcherDescription', (WidgetTester tester) async { final List log = []; SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async { diff --git a/packages/flutter/test/widgets/tracking_scroll_controller_test.dart b/packages/flutter/test/widgets/tracking_scroll_controller_test.dart index 438a0bd19d..4e0c77d0cd 100644 --- a/packages/flutter/test/widgets/tracking_scroll_controller_test.dart +++ b/packages/flutter/test/widgets/tracking_scroll_controller_test.dart @@ -6,8 +6,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - testWidgets('TrackingScrollController saves offset', - (WidgetTester tester) async { + testWidgets('TrackingScrollController saves offset', (WidgetTester tester) async { final TrackingScrollController controller = TrackingScrollController(); const double listItemHeight = 100.0; diff --git a/packages/flutter/test/widgets/transitions_test.dart b/packages/flutter/test/widgets/transitions_test.dart index a1403b30a2..a72dfccc12 100644 --- a/packages/flutter/test/widgets/transitions_test.dart +++ b/packages/flutter/test/widgets/transitions_test.dart @@ -282,8 +282,7 @@ void main() { expect(actualTurns, Matrix4.rotationZ(math.pi * 1.5)); }); - testWidgets('RotationTransition maintains chosen alignment during animation', - (WidgetTester tester) async { + testWidgets('RotationTransition maintains chosen alignment during animation', (WidgetTester tester) async { final AnimationController controller = AnimationController(vsync: const TestVSync()); final Widget widget = RotationTransition( alignment: Alignment.topRight, diff --git a/packages/flutter/test/widgets/widget_inspector_test.dart b/packages/flutter/test/widgets/widget_inspector_test.dart index eeab1779c6..eb3c9cd421 100644 --- a/packages/flutter/test/widgets/widget_inspector_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_test.dart @@ -1281,7 +1281,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { // the RichText object not the Text element. final Map regularSelection = await service.testExtension('getSelectedWidget', {'arg': null, 'objectGroup': 'my-group'}); expect(service.toObject(regularSelection['valueId']), richTextDiagnostic.value); - }, skip: !WidgetInspectorService.instance.isWidgetCreationTracked()); // Test requires --track-widget-creation flag. + }, skip: !WidgetInspectorService.instance.isWidgetCreationTracked()); // Test requires --track-widget-creation flag. testWidgets('ext.flutter.inspector creationLocation', (WidgetTester tester) async { await tester.pumpWidget( @@ -1760,8 +1760,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { expect(WidgetsApp.debugShowWidgetInspectorOverride, isFalse); }); - testWidgets('ext.flutter.inspector.screenshot', - (WidgetTester tester) async { + testWidgets('ext.flutter.inspector.screenshot', (WidgetTester tester) async { final GlobalKey outerContainerKey = GlobalKey(); final GlobalKey paddingKey = GlobalKey(); final GlobalKey redContainerKey = GlobalKey(); diff --git a/packages/flutter_driver/lib/src/common/error.dart b/packages/flutter_driver/lib/src/common/error.dart index 2655c5be36..e0c8e4ebe4 100644 --- a/packages/flutter_driver/lib/src/common/error.dart +++ b/packages/flutter_driver/lib/src/common/error.dart @@ -34,9 +34,9 @@ $originalStackTrace bool _noLogSubscribers = true; final StreamController _logger = - StreamController.broadcast(sync: true, onListen: () { - _noLogSubscribers = false; - }); + StreamController.broadcast(sync: true, onListen: () { + _noLogSubscribers = false; + }); void _log(LogLevel level, String loggerName, Object message) { final LogRecord record = LogRecord._(level, loggerName, '$message'); diff --git a/packages/flutter_driver/test/flutter_driver_test.dart b/packages/flutter_driver/test/flutter_driver_test.dart index a9f5278580..ad6a94a728 100644 --- a/packages/flutter_driver/test/flutter_driver_test.dart +++ b/packages/flutter_driver/test/flutter_driver_test.dart @@ -236,10 +236,10 @@ void main() { test('clears timeline', () async { bool clearWasCalled = false; when(mockPeer.sendRequest('_clearVMTimeline', argThat(equals({})))) - .thenAnswer((Invocation invocation) async { - clearWasCalled = true; - return null; - }); + .thenAnswer((Invocation invocation) async { + clearWasCalled = true; + return null; + }); await driver.clearTimeline(); expect(clearWasCalled, isTrue); }); @@ -252,22 +252,22 @@ void main() { log = []; when(mockPeer.sendRequest('_clearVMTimeline', argThat(equals({})))) - .thenAnswer((Invocation invocation) async { - log.add('clear'); - return null; - }); + .thenAnswer((Invocation invocation) async { + log.add('clear'); + return null; + }); when(mockPeer.sendRequest('_setVMTimelineFlags', argThat(equals({'recordedStreams': '[all]'})))) - .thenAnswer((Invocation invocation) async { - log.add('startTracing'); - return null; - }); + .thenAnswer((Invocation invocation) async { + log.add('startTracing'); + return null; + }); when(mockPeer.sendRequest('_setVMTimelineFlags', argThat(equals({'recordedStreams': '[]'})))) - .thenAnswer((Invocation invocation) async { - log.add('stopTracing'); - return null; - }); + .thenAnswer((Invocation invocation) async { + log.add('stopTracing'); + return null; + }); when(mockPeer.sendRequest('_getVMTimeline')).thenAnswer((Invocation invocation) async { log.add('download'); diff --git a/packages/flutter_driver/test/src/extension_test.dart b/packages/flutter_driver/test/src/extension_test.dart index 58979e33fc..1d3718b36f 100644 --- a/packages/flutter_driver/test/src/extension_test.dart +++ b/packages/flutter_driver/test/src/extension_test.dart @@ -24,9 +24,9 @@ void main() { testWidgets('returns immediately when transient callback queue is empty', (WidgetTester tester) async { extension.call(WaitUntilNoTransientCallbacks().serialize()) - .then(expectAsync1((Map r) { - result = r; - })); + .then(expectAsync1((Map r) { + result = r; + })); await tester.idle(); expect( @@ -44,9 +44,9 @@ void main() { }); extension.call(WaitUntilNoTransientCallbacks().serialize()) - .then(expectAsync1((Map r) { - result = r; - })); + .then(expectAsync1((Map r) { + result = r; + })); // Nothing should happen until the next frame. await tester.idle(); diff --git a/packages/flutter_localizations/test/date_time_test.dart b/packages/flutter_localizations/test/date_time_test.dart index 8710253f60..6e0274a2f2 100644 --- a/packages/flutter_localizations/test/date_time_test.dart +++ b/packages/flutter_localizations/test/date_time_test.dart @@ -140,11 +140,11 @@ void main() { } testWidgets('formats dates in English', (WidgetTester tester) async { - final Map formatted = await formatDate(tester, const Locale('en'), DateTime(2018, 8, 1)); - expect(formatted[DateType.year], '2018'); - expect(formatted[DateType.medium], 'Wed, Aug 1'); - expect(formatted[DateType.full], 'Wednesday, August 1, 2018'); - expect(formatted[DateType.monthYear], 'August 2018'); + final Map formatted = await formatDate(tester, const Locale('en'), DateTime(2018, 8, 1)); + expect(formatted[DateType.year], '2018'); + expect(formatted[DateType.medium], 'Wed, Aug 1'); + expect(formatted[DateType.full], 'Wednesday, August 1, 2018'); + expect(formatted[DateType.monthYear], 'August 2018'); }); testWidgets('formats dates in German', (WidgetTester tester) async { diff --git a/packages/flutter_test/lib/src/widget_tester.dart b/packages/flutter_test/lib/src/widget_tester.dart index 4dccacbe0a..0b79c24725 100644 --- a/packages/flutter_test/lib/src/widget_tester.dart +++ b/packages/flutter_test/lib/src/widget_tester.dart @@ -302,9 +302,9 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker /// advances the clock. Future pumpBenchmark(Duration duration) async { assert(() { - final TestWidgetsFlutterBinding widgetsBinding = binding; - return widgetsBinding is LiveTestWidgetsFlutterBinding && - widgetsBinding.framePolicy == LiveTestWidgetsFlutterBindingFramePolicy.benchmark; + final TestWidgetsFlutterBinding widgetsBinding = binding; + return widgetsBinding is LiveTestWidgetsFlutterBinding && + widgetsBinding.framePolicy == LiveTestWidgetsFlutterBindingFramePolicy.benchmark; }()); dynamic caughtException; diff --git a/packages/flutter_test/test/matchers_test.dart b/packages/flutter_test/test/matchers_test.dart index 6be8be5898..82058b5250 100644 --- a/packages/flutter_test/test/matchers_test.dart +++ b/packages/flutter_test/test/matchers_test.dart @@ -273,7 +273,7 @@ void main() { ); }); - test('partially overlapping paths', () { + test('partially overlapping paths', () { final Path rectPath = Path() ..addRect(Rect.fromLTRB(5.0, 5.0, 6.0, 6.0)); final Path linePath = Path() diff --git a/packages/flutter_test/test/test_text_input_test.dart b/packages/flutter_test/test/test_text_input_test.dart index 2bed6132df..5897a53c31 100644 --- a/packages/flutter_test/test/test_text_input_test.dart +++ b/packages/flutter_test/test/test_text_input_test.dart @@ -7,8 +7,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - testWidgets('receiveAction() forwards exception when exception occurs during action processing', - (WidgetTester tester) async { + testWidgets('receiveAction() forwards exception when exception occurs during action processing', (WidgetTester tester) async { // Setup a widget that can receive focus so that we can open the keyboard. const Widget widget = MaterialApp( home: Material( diff --git a/packages/flutter_tools/lib/src/bundle.dart b/packages/flutter_tools/lib/src/bundle.dart index def7e442fe..902432e442 100644 --- a/packages/flutter_tools/lib/src/bundle.dart +++ b/packages/flutter_tools/lib/src/bundle.dart @@ -230,9 +230,9 @@ Future writeBundle( bundleDir.createSync(recursive: true); await Future.wait( - assetEntries.entries.map>((MapEntry entry) async { - final File file = fs.file(fs.path.join(bundleDir.path, entry.key)); - file.parent.createSync(recursive: true); - await file.writeAsBytes(await entry.value.contentsAsBytes()); - })); + assetEntries.entries.map>((MapEntry entry) async { + final File file = fs.file(fs.path.join(bundleDir.path, entry.key)); + file.parent.createSync(recursive: true); + await file.writeAsBytes(await entry.value.contentsAsBytes()); + })); } diff --git a/packages/flutter_tools/lib/src/commands/channel.dart b/packages/flutter_tools/lib/src/commands/channel.dart index dce73af803..1b0bd0fdbe 100644 --- a/packages/flutter_tools/lib/src/commands/channel.dart +++ b/packages/flutter_tools/lib/src/commands/channel.dart @@ -37,7 +37,7 @@ class ChannelCommand extends FlutterCommand { case 0: await _listChannels( showAll: argResults['all'], - verbose: globalResults['verbose'] + verbose: globalResults['verbose'], ); return null; case 1: diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart index 9d954929a4..074caae063 100644 --- a/packages/flutter_tools/lib/src/commands/daemon.dart +++ b/packages/flutter_tools/lib/src/commands/daemon.dart @@ -983,9 +983,8 @@ class _AppRunLogger extends Logger { 'id': id.toString(), 'progressId': progressId, 'finished': true, - }, - ); - })..start(); + }); + })..start(); return _status; } diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index 86d895dfc5..fed4e4eebd 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -259,10 +259,10 @@ class KernelCompiler { printTrace(command.join(' ')); final Process server = await processManager - .start(command) - .catchError((dynamic error, StackTrace stack) { - printError('Failed to start frontend server $error, $stack'); - }); + .start(command) + .catchError((dynamic error, StackTrace stack) { + printError('Failed to start frontend server $error, $stack'); + }); final StdoutHandler _stdoutHandler = StdoutHandler(); diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart index 26a6b2b056..f479501438 100644 --- a/packages/flutter_tools/lib/src/project.dart +++ b/packages/flutter_tools/lib/src/project.dart @@ -490,7 +490,7 @@ class WebProject { printStatusWhenWriting: false, overwriteExisting: true, ); - } + } } /// Deletes [directory] with all content. diff --git a/packages/flutter_tools/lib/src/tester/flutter_tester.dart b/packages/flutter_tools/lib/src/tester/flutter_tester.dart index 463d84c812..1e7d1cdf20 100644 --- a/packages/flutter_tools/lib/src/tester/flutter_tester.dart +++ b/packages/flutter_tools/lib/src/tester/flutter_tester.dart @@ -154,17 +154,17 @@ class FlutterTesterDevice extends Device { // Setting a bool can't fail in the callback. unawaited(_process.exitCode.then((_) => _isRunning = false)); _process.stdout - .transform(utf8.decoder) - .transform(const LineSplitter()) - .listen((String line) { - _logReader.addLine(line); - }); + .transform(utf8.decoder) + .transform(const LineSplitter()) + .listen((String line) { + _logReader.addLine(line); + }); _process.stderr - .transform(utf8.decoder) - .transform(const LineSplitter()) - .listen((String line) { - _logReader.addLine(line); - }); + .transform(utf8.decoder) + .transform(const LineSplitter()) + .listen((String line) { + _logReader.addLine(line); + }); if (!debuggingOptions.debuggingEnabled) return LaunchResult.succeeded(); diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index 8a5a711752..e2c2890908 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -1428,14 +1428,14 @@ class FlutterView extends ServiceObject { final Completer completer = Completer(); final StreamSubscription subscription = (await owner.vm.vmService.onIsolateEvent).listen((ServiceEvent event) { - // TODO(johnmccutchan): Listen to the debug stream and catch initial - // launch errors. - if (event.kind == ServiceEvent.kIsolateRunnable) { - printTrace('Isolate is runnable.'); - if (!completer.isCompleted) - completer.complete(); - } - }); + // TODO(johnmccutchan): Listen to the debug stream and catch initial + // launch errors. + if (event.kind == ServiceEvent.kIsolateRunnable) { + printTrace('Isolate is runnable.'); + if (!completer.isCompleted) + completer.complete(); + } + }); await owner.vm.runInView(viewId, entryUri, packagesUri, diff --git a/packages/flutter_tools/test/commands/attach_test.dart b/packages/flutter_tools/test/commands/attach_test.dart index f2a7020b60..693d71e3df 100644 --- a/packages/flutter_tools/test/commands/attach_test.dart +++ b/packages/flutter_tools/test/commands/attach_test.dart @@ -237,8 +237,8 @@ void main() { mockLogReader.addLine( 'Observatory listening on http://127.0.0.1:$devicePort'); }); - return mockLogReader; - }); + return mockLogReader; + }); final File foo = fs.file('lib/foo.dart') ..createSync(); diff --git a/packages/flutter_tools/test/commands/doctor_test.dart b/packages/flutter_tools/test/commands/doctor_test.dart index 5329d47d2b..3fe74bb267 100644 --- a/packages/flutter_tools/test/commands/doctor_test.dart +++ b/packages/flutter_tools/test/commands/doctor_test.dart @@ -133,8 +133,7 @@ void main() { ..environment = {'http_proxy': 'fakeproxy.local'}, }); - testUsingContext('reports success when NO_PROXY is configured correctly', - () async { + testUsingContext('reports success when NO_PROXY is configured correctly', () async { final ValidationResult results = await ProxyValidator().validate(); final List issues = results.messages .where((ValidationMessage msg) => msg.isError || msg.isHint) @@ -148,8 +147,7 @@ void main() { }, }); - testUsingContext('reports success when no_proxy is configured correctly', - () async { + testUsingContext('reports success when no_proxy is configured correctly', () async { final ValidationResult results = await ProxyValidator().validate(); final List issues = results.messages .where((ValidationMessage msg) => msg.isError || msg.isHint) @@ -163,8 +161,7 @@ void main() { }, }); - testUsingContext('reports issues when NO_PROXY is missing localhost', - () async { + testUsingContext('reports issues when NO_PROXY is missing localhost', () async { final ValidationResult results = await ProxyValidator().validate(); final List issues = results.messages .where((ValidationMessage msg) => msg.isError || msg.isHint) @@ -178,8 +175,7 @@ void main() { }, }); - testUsingContext('reports issues when NO_PROXY is missing 127.0.0.1', - () async { + testUsingContext('reports issues when NO_PROXY is missing 127.0.0.1', () async { final ValidationResult results = await ProxyValidator().validate(); final List issues = results.messages .where((ValidationMessage msg) => msg.isError || msg.isHint) diff --git a/packages/flutter_tools/test/commands/ide_config_test.dart b/packages/flutter_tools/test/commands/ide_config_test.dart index 4f4bf24dba..70348ea64d 100644 --- a/packages/flutter_tools/test/commands/ide_config_test.dart +++ b/packages/flutter_tools/test/commands/ide_config_test.dart @@ -23,10 +23,10 @@ void main() { Map _getFilesystemContents([ Directory root ]) { final String tempPath = tempDir.absolute.path; final List paths = - (root ?? tempDir).listSync(recursive: true).map((FileSystemEntity entity) { - final String relativePath = fs.path.relative(entity.path, from: tempPath); - return relativePath; - }).toList(); + (root ?? tempDir).listSync(recursive: true).map((FileSystemEntity entity) { + final String relativePath = fs.path.relative(entity.path, from: tempPath); + return relativePath; + }).toList(); final Map contents = {}; for (String path in paths) { final String absPath = fs.path.join(tempPath, path); diff --git a/packages/flutter_tools/test/emulator_test.dart b/packages/flutter_tools/test/emulator_test.dart index 2fdef5b446..44a39bb9fa 100644 --- a/packages/flutter_tools/test/emulator_test.dart +++ b/packages/flutter_tools/test/emulator_test.dart @@ -70,8 +70,7 @@ void main() { await expectEmulator('ios', [emulator3]); }); - testUsingContext('create emulator with an empty name does not fail', - () async { + testUsingContext('create emulator with an empty name does not fail', () async { final CreateEmulatorResult res = await emulatorManager.createEmulator(); expect(res.success, equals(true)); }, overrides: { @@ -80,8 +79,7 @@ void main() { AndroidSdk: () => mockSdk, }); - testUsingContext('create emulator with a unique name does not throw', - () async { + testUsingContext('create emulator with a unique name does not throw', () async { final CreateEmulatorResult res = await emulatorManager.createEmulator(name: 'test'); expect(res.success, equals(true)); @@ -101,9 +99,7 @@ void main() { AndroidSdk: () => mockSdk, }); - testUsingContext( - 'create emulator without a name but when default exists adds a suffix', - () async { + testUsingContext('create emulator without a name but when default exists adds a suffix', () async { // First will get default name. CreateEmulatorResult res = await emulatorManager.createEmulator(); expect(res.success, equals(true)); diff --git a/packages/flutter_tools/test/flutter_manifest_test.dart b/packages/flutter_tools/test/flutter_manifest_test.dart index 828bc6f331..c2156bf357 100644 --- a/packages/flutter_tools/test/flutter_manifest_test.dart +++ b/packages/flutter_tools/test/flutter_manifest_test.dart @@ -499,14 +499,15 @@ flutter: FileSystem filesystem, dynamic testMethod(), ) { - testUsingContext(description, - () async { - writeEmptySchemaFile(filesystem); - testMethod(); - }, - overrides: { - FileSystem: () => filesystem, - }, + testUsingContext( + description, + () async { + writeEmptySchemaFile(filesystem); + testMethod(); + }, + overrides: { + FileSystem: () => filesystem, + }, ); } @@ -514,16 +515,20 @@ flutter: assertSchemaIsReadable(); }); - testUsingContextAndFs('Validate manifest on Posix FS', - MemoryFileSystem(style: FileSystemStyle.posix), () { - assertSchemaIsReadable(); - }, + testUsingContextAndFs( + 'Validate manifest on Posix FS', + MemoryFileSystem(style: FileSystemStyle.posix), + () { + assertSchemaIsReadable(); + }, ); - testUsingContextAndFs('Validate manifest on Windows FS', - MemoryFileSystem(style: FileSystemStyle.windows), () { - assertSchemaIsReadable(); - }, + testUsingContextAndFs( + 'Validate manifest on Windows FS', + MemoryFileSystem(style: FileSystemStyle.windows), + () { + assertSchemaIsReadable(); + }, ); }); diff --git a/packages/flutter_tools/test/integration/daemon_mode_test.dart b/packages/flutter_tools/test/integration/daemon_mode_test.dart index 8771b602fb..c63fc3360f 100644 --- a/packages/flutter_tools/test/integration/daemon_mode_test.dart +++ b/packages/flutter_tools/test/integration/daemon_mode_test.dart @@ -47,18 +47,18 @@ void main() { .listen((String line) => stdout.add(line)); final Stream> stream = - stdout.stream.where((String line) { - final Map response = parseFlutterResponse(line); - // ignore 'Starting device daemon...' - if (response == null) { - return false; - } - // TODO(devoncarew): Remove this after #25440 lands. - if (response['event'] == 'daemon.showMessage') { - return false; - } - return true; - }).map(parseFlutterResponse); + stdout.stream.where((String line) { + final Map response = parseFlutterResponse(line); + // ignore 'Starting device daemon...' + if (response == null) { + return false; + } + // TODO(devoncarew): Remove this after #25440 lands. + if (response['event'] == 'daemon.showMessage') { + return false; + } + return true; + }).map(parseFlutterResponse); Map response = await stream.first; expect(response['event'], 'daemon.connected'); diff --git a/packages/flutter_tools/test/ios/simulators_test.dart b/packages/flutter_tools/test/ios/simulators_test.dart index ba2d8be81a..bc3ea0790c 100644 --- a/packages/flutter_tools/test/ios/simulators_test.dart +++ b/packages/flutter_tools/test/ios/simulators_test.dart @@ -305,21 +305,23 @@ void main() { testUsingContext('simulator can output `)`', () async { when(mockProcessManager.start(any, environment: null, workingDirectory: null)) - .thenAnswer((Invocation invocation) { - final Process mockProcess = MockProcess(); - when(mockProcess.stdout).thenAnswer((Invocation invocation) => - Stream>.fromIterable(>[''' + .thenAnswer((Invocation invocation) { + final Process mockProcess = MockProcess(); + when(mockProcess.stdout) + .thenAnswer((Invocation invocation) { + return Stream>.fromIterable(>[''' 2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) Observatory listening on http://127.0.0.1:57701/ 2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) )))))))))) 2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) #0 Object.noSuchMethod (dart:core-patch/dart:core/object_patch.dart:46)''' - .codeUnits])); - when(mockProcess.stderr) - .thenAnswer((Invocation invocation) => const Stream>.empty()); - // Delay return of exitCode until after stdout stream data, since it terminates the logger. - when(mockProcess.exitCode) - .thenAnswer((Invocation invocation) => Future.delayed(Duration.zero, () => 0)); - return Future.value(mockProcess); - }); + .codeUnits]); + }); + when(mockProcess.stderr) + .thenAnswer((Invocation invocation) => const Stream>.empty()); + // Delay return of exitCode until after stdout stream data, since it terminates the logger. + when(mockProcess.exitCode) + .thenAnswer((Invocation invocation) => Future.delayed(Duration.zero, () => 0)); + return Future.value(mockProcess); + }); final IOSSimulator device = IOSSimulator('123456', category: 'iOS 11.0'); final DeviceLogReader logReader = device.getLogReader( diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart b/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart index 56b2abe978..5075e06e7a 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart @@ -164,13 +164,13 @@ class DartVm { Duration timeout = _kRpcTimeout, }) async { final Map result = await _peer - .sendRequest(function, params ?? {}) - .timeout(timeout, onTimeout: () { - throw TimeoutException( - 'Peer connection timed out during RPC call', - timeout, - ); - }); + .sendRequest(function, params ?? {}) + .timeout(timeout, onTimeout: () { + throw TimeoutException( + 'Peer connection timed out during RPC call', + timeout, + ); + }); return result; } diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart b/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart index 88c62a19cb..8af956194a 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart @@ -321,21 +321,21 @@ class FuchsiaRemoteConnection { )); } final List result = - await Future.wait>(isolates) - .timeout(timeout) - .then>((List> listOfLists) { - final List> mutableListOfLists = - List>.from(listOfLists) - ..retainWhere((List list) => list.isNotEmpty); - // Folds the list of lists into one flat list. - return mutableListOfLists.fold>( - [], - (List accumulator, List element) { - accumulator.addAll(element); - return accumulator; - }, - ); - }); + await Future.wait>(isolates) + .timeout(timeout) + .then>((List> listOfLists) { + final List> mutableListOfLists = + List>.from(listOfLists) + ..retainWhere((List list) => list.isNotEmpty); + // Folds the list of lists into one flat list. + return mutableListOfLists.fold>( + [], + (List accumulator, List element) { + accumulator.addAll(element); + return accumulator; + }, + ); + }); // If no VM instance anywhere has this, it's possible it hasn't spun up // anywhere. @@ -497,14 +497,14 @@ class FuchsiaRemoteConnection { await stop(); final List servicePorts = await getDeviceServicePorts(); final List forwardedVmServicePorts = - await Future.wait( - servicePorts.map>((int deviceServicePort) { - return fuchsiaPortForwardingFunction( - _sshCommandRunner.address, - deviceServicePort, - _sshCommandRunner.interface, - _sshCommandRunner.sshConfigPath); - })); + await Future.wait( + servicePorts.map>((int deviceServicePort) { + return fuchsiaPortForwardingFunction( + _sshCommandRunner.address, + deviceServicePort, + _sshCommandRunner.interface, + _sshCommandRunner.sshConfigPath); + })); for (PortForwarder pf in forwardedVmServicePorts) { // TODO(awdavies): Handle duplicates. diff --git a/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart b/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart index d668dbdfe0..4fb183ba1e 100644 --- a/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart +++ b/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart @@ -120,8 +120,7 @@ void main() { restoreVmServiceConnectionFunction(); }); - test('end-to-end with three vm connections and flutter view query', - () async { + test('end-to-end with three vm connections and flutter view query', () async { final FuchsiaRemoteConnection connection = await FuchsiaRemoteConnection.connectWithSshCommandRunner(mockRunner); diff --git a/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart b/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart index 46c4fc65cb..8e61cf5620 100644 --- a/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart +++ b/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart @@ -21,8 +21,7 @@ void main() { expect(newCommandRunner, throwsArgumentError); }); - test('throws exception from injection constructor with invalid addr', - () async { + test('throws exception from injection constructor with invalid addr', () async { SshCommandRunner newCommandRunner() { return SshCommandRunner.withProcessManager( const LocalProcessManager(), @@ -62,8 +61,7 @@ void main() { expect(passedCommand, contains('$ipV6Addr%$interface')); }); - test('verify no percentage symbol is added when no ipv6 interface', - () async { + test('verify no percentage symbol is added when no ipv6 interface', () async { const String ipV6Addr = 'fe80::8eae:4cff:fef4:9247'; runner = SshCommandRunner.withProcessManager( mockProcessManager,