From 5684b9f69e86712107b14c39dcbcd16c7d4dc08f Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Fri, 21 Jan 2022 14:43:59 -0800 Subject: [PATCH] Enable no_leading_underscores_for_local_identifiers (#96422) --- analysis_options.yaml | 2 +- .../test/measure_scroll_smoothness.dart | 6 +- dev/benchmarks/macrobenchmarks/test/util.dart | 6 +- .../matrix_utils_transform_bench.dart | 44 +++--- dev/devicelab/lib/framework/browser.dart | 2 +- dev/devicelab/lib/tasks/gallery.dart | 6 +- dev/devicelab/test/cocoon_test.dart | 22 +-- .../interactive_viewer.constrained.0.dart | 10 +- .../nested_scroll_view.0.dart | 8 +- .../notification_listener/notification.0.dart | 23 ++-- .../src/animation/animation_controller.dart | 4 +- .../flutter/lib/src/cupertino/colors.dart | 6 +- .../lib/src/cupertino/page_scaffold.dart | 6 +- .../lib/src/cupertino/segmented_control.dart | 12 +- .../lib/src/foundation/_bitfield_io.dart | 14 +- .../lib/src/foundation/change_notifier.dart | 4 +- packages/flutter/lib/src/material/chip.dart | 4 +- .../flutter/lib/src/material/list_tile.dart | 4 +- .../src/material/material_state_mixin.dart | 12 +- .../lib/src/material/range_slider.dart | 32 ++--- .../flutter/lib/src/material/scaffold.dart | 30 ++-- packages/flutter/lib/src/material/slider.dart | 28 ++-- .../flutter/lib/src/material/theme_data.dart | 14 +- .../flutter/lib/src/material/time_picker.dart | 4 +- packages/flutter/lib/src/rendering/box.dart | 10 +- .../flutter/lib/src/rendering/object.dart | 4 +- .../flutter/lib/src/services/binding.dart | 4 +- .../lib/src/services/keyboard_key.dart | 4 +- .../lib/src/widgets/nested_scroll_view.dart | 4 +- .../src/widgets/restoration_properties.dart | 8 +- .../cupertino/context_menu_action_test.dart | 27 ++-- .../test/cupertino/context_menu_test.dart | 6 +- .../flutter/test/cupertino/route_test.dart | 4 +- .../test/cupertino/scrollbar_test.dart | 60 ++++---- .../cupertino/text_form_field_row_test.dart | 44 +++--- .../material/bottom_navigation_bar_test.dart | 18 +-- .../material/checkbox_list_tile_test.dart | 34 ++--- .../flutter/test/material/checkbox_test.dart | 16 +-- .../test/material/data_table_test.dart | 104 +++++++------- .../flutter/test/material/debug_test.dart | 12 +- .../flutter/test/material/dialog_test.dart | 6 +- .../material/dropdown_form_field_test.dart | 14 +- .../test/material/expansion_panel_test.dart | 128 +++++++++--------- .../test/material/expansion_tile_test.dart | 42 +++--- .../test/material/navigation_bar_test.dart | 4 +- .../material/paginated_data_table_test.dart | 124 ++++++++--------- .../test/material/popup_menu_test.dart | 6 +- packages/flutter/test/material/tabs_test.dart | 22 +-- .../test/material/text_form_field_test.dart | 44 +++--- .../flutter/test/material/theme_test.dart | 8 +- .../test/material/toggle_buttons_test.dart | 26 ++-- .../flutter/test/material/tooltip_test.dart | 20 +-- .../flutter/test/rendering/error_test.dart | 14 +- .../rendering/mouse_tracker_cursor_test.dart | 24 ++-- .../test/rendering/mouse_tracker_test.dart | 52 +++---- packages/flutter/test/widgets/basic_test.dart | 24 ++-- .../flutter/test/widgets/fitted_box_test.dart | 8 +- .../flutter/test/widgets/image_icon_test.dart | 11 +- .../test/widgets/inherited_model_test.dart | 76 +++++------ .../test/widgets/nested_scroll_view_test.dart | 8 +- .../flutter/test/widgets/routes_test.dart | 12 +- .../flutter/test/widgets/transform_test.dart | 44 +++--- .../lib/src/common/handler_factory.dart | 10 +- .../flutter_test/lib/src/animation_sheet.dart | 2 +- packages/flutter_test/lib/src/binding.dart | 10 +- .../flutter_test/test/accessibility_test.dart | 42 +++--- .../lib/src/commands/ide_config.dart | 4 +- .../lib/src/debug_adapters/server.dart | 6 +- packages/flutter_tools/lib/src/version.dart | 2 +- .../test/general.shard/ios/xcresult_test.dart | 8 +- .../test/general.shard/utils_test.dart | 64 ++++----- .../integration.shard/daemon_mode_test.dart | 4 +- .../debug_adapter/flutter_adapter_test.dart | 42 +++--- .../debug_adapter/test_server.dart | 4 +- .../debugger_stepping_test.dart | 24 ++-- .../deferred_components_test.dart | 6 +- .../expression_evaluation_test.dart | 92 ++++++------- .../flutter_attach_test.dart | 60 ++++---- .../integration.shard/flutter_run_test.dart | 30 ++-- .../flutter_run_with_error_test.dart | 22 +-- .../test/integration.shard/lifetime_test.dart | 18 +-- .../multidex_build_test.dart | 6 +- .../observatory_port_test.dart | 4 +- .../stateless_stateful_hot_reload_test.dart | 24 ++-- .../test/integration.shard/test_driver.dart | 8 +- .../vmservice_integration_test.dart | 4 +- .../web.shard/debugger_stepping_web_test.dart | 12 +- .../lib/src/navigation/url_strategy.dart | 6 +- .../src/navigation_non_web/url_strategy.dart | 4 +- 89 files changed, 948 insertions(+), 949 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 5cc87bc768..852ade4267 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -136,7 +136,7 @@ linter: - no_default_cases - no_duplicate_case_values - no_leading_underscores_for_library_prefixes - # - no_leading_underscores_for_local_identifiers # not yet tested + - no_leading_underscores_for_local_identifiers - no_logic_in_create_state # - no_runtimeType_toString # ok in tests; we enable this only in packages/ - non_constant_identifier_names diff --git a/dev/benchmarks/complex_layout/test/measure_scroll_smoothness.dart b/dev/benchmarks/complex_layout/test/measure_scroll_smoothness.dart index 26ae2f2375..9c6d70e7d3 100644 --- a/dev/benchmarks/complex_layout/test/measure_scroll_smoothness.dart +++ b/dev/benchmarks/complex_layout/test/measure_scroll_smoothness.dart @@ -120,9 +120,9 @@ class ResampleFlagVariant extends TestVariant { } Future main() async { - final WidgetsBinding _binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - assert(_binding is IntegrationTestWidgetsFlutterBinding); - final IntegrationTestWidgetsFlutterBinding binding = _binding as IntegrationTestWidgetsFlutterBinding; + final WidgetsBinding widgetsBinding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + assert(widgetsBinding is IntegrationTestWidgetsFlutterBinding); + final IntegrationTestWidgetsFlutterBinding binding = widgetsBinding as IntegrationTestWidgetsFlutterBinding; binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.benchmarkLive; binding.reportData ??= {}; final ResampleFlagVariant variant = ResampleFlagVariant(binding); diff --git a/dev/benchmarks/macrobenchmarks/test/util.dart b/dev/benchmarks/macrobenchmarks/test/util.dart index 015da80449..7987ad8b0a 100644 --- a/dev/benchmarks/macrobenchmarks/test/util.dart +++ b/dev/benchmarks/macrobenchmarks/test/util.dart @@ -38,9 +38,9 @@ void macroPerfTestMultiPageE2E( ControlCallback? body, ControlCallback? setup, }) { - final WidgetsBinding _binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - assert(_binding is IntegrationTestWidgetsFlutterBinding); - final IntegrationTestWidgetsFlutterBinding binding = _binding as IntegrationTestWidgetsFlutterBinding; + final WidgetsBinding widgetsBinding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + assert(widgetsBinding is IntegrationTestWidgetsFlutterBinding); + final IntegrationTestWidgetsFlutterBinding binding = widgetsBinding as IntegrationTestWidgetsFlutterBinding; binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.benchmarkLive; testWidgets(testName, (WidgetTester tester) async { diff --git a/dev/benchmarks/microbenchmarks/lib/geometry/matrix_utils_transform_bench.dart b/dev/benchmarks/microbenchmarks/lib/geometry/matrix_utils_transform_bench.dart index 33a4e17f35..0800f5254f 100644 --- a/dev/benchmarks/microbenchmarks/lib/geometry/matrix_utils_transform_bench.dart +++ b/dev/benchmarks/microbenchmarks/lib/geometry/matrix_utils_transform_bench.dart @@ -23,47 +23,47 @@ void main() { ); } - final List _affineTransforms = [ + final List affineTransforms = [ Matrix4.identity()..scale(1.2, 1.3, 1.0)..rotateZ(0.1), Matrix4.identity()..translate(12.0, 13.0, 10.0), Matrix4.identity()..scale(1.2, 1.3, 1.0)..translate(12.0, 13.0, 10.0), ]; - final List _perspectiveTransforms = [ + final List perspectiveTransforms = [ _makePerspective(10.0, math.pi / 8.0, 0.3), _makePerspective( 8.0, math.pi / 8.0, 0.2), _makePerspective( 1.0, math.pi / 4.0, 0.1)..rotateX(0.1), ]; - final List _rectangles = [ + final List rectangles = [ const Rect.fromLTRB(1.1, 1.2, 1.5, 1.8), const Rect.fromLTRB(1.1, 1.2, 0.0, 1.0), const Rect.fromLTRB(1.1, 1.2, 1.3, 1.0), const Rect.fromLTRB(-1.1, -1.2, 0.0, 1.0), const Rect.fromLTRB(-1.1, -1.2, -1.5, -1.8), ]; - final List _offsets = [ + final List offsets = [ const Offset(1.1, 1.2), const Offset(1.5, 1.8), Offset.zero, const Offset(-1.1, -1.2), const Offset(-1.5, -1.8), ]; - final int nAffine = _affineTransforms.length; - final int nPerspective = _perspectiveTransforms.length; - final int nRectangles = _rectangles.length; - final int nOffsets = _offsets.length; + final int nAffine = affineTransforms.length; + final int nPerspective = perspectiveTransforms.length; + final int nRectangles = rectangles.length; + final int nOffsets = offsets.length; // Warm up lap for (int i = 0; i < _kNumWarmUp; i += 1) { - final Matrix4 transform = _perspectiveTransforms[i % nPerspective]; - final Rect rect = _rectangles[(i ~/ nPerspective) % nRectangles]; - final Offset offset = _offsets[(i ~/ nPerspective) % nOffsets]; + final Matrix4 transform = perspectiveTransforms[i % nPerspective]; + final Rect rect = rectangles[(i ~/ nPerspective) % nRectangles]; + final Offset offset = offsets[(i ~/ nPerspective) % nOffsets]; MatrixUtils.transformRect(transform, rect); MatrixUtils.transformPoint(transform, offset); } for (int i = 0; i < _kNumWarmUp; i += 1) { - final Matrix4 transform = _affineTransforms[i % nAffine]; - final Rect rect = _rectangles[(i ~/ nAffine) % nRectangles]; - final Offset offset = _offsets[(i ~/ nAffine) % nOffsets]; + final Matrix4 transform = affineTransforms[i % nAffine]; + final Rect rect = rectangles[(i ~/ nAffine) % nRectangles]; + final Offset offset = offsets[(i ~/ nAffine) % nOffsets]; MatrixUtils.transformRect(transform, rect); MatrixUtils.transformPoint(transform, offset); } @@ -71,8 +71,8 @@ void main() { final Stopwatch watch = Stopwatch(); watch.start(); for (int i = 0; i < _kNumIterations; i += 1) { - final Matrix4 transform = _perspectiveTransforms[i % nPerspective]; - final Rect rect = _rectangles[(i ~/ nPerspective) % nRectangles]; + final Matrix4 transform = perspectiveTransforms[i % nPerspective]; + final Rect rect = rectangles[(i ~/ nPerspective) % nRectangles]; MatrixUtils.transformRect(transform, rect); } watch.stop(); @@ -81,8 +81,8 @@ void main() { watch.reset(); watch.start(); for (int i = 0; i < _kNumIterations; i += 1) { - final Matrix4 transform = _affineTransforms[i % nAffine]; - final Rect rect = _rectangles[(i ~/ nAffine) % nRectangles]; + final Matrix4 transform = affineTransforms[i % nAffine]; + final Rect rect = rectangles[(i ~/ nAffine) % nRectangles]; MatrixUtils.transformRect(transform, rect); } watch.stop(); @@ -91,8 +91,8 @@ void main() { watch.reset(); watch.start(); for (int i = 0; i < _kNumIterations; i += 1) { - final Matrix4 transform = _perspectiveTransforms[i % nPerspective]; - final Offset offset = _offsets[(i ~/ nPerspective) % nOffsets]; + final Matrix4 transform = perspectiveTransforms[i % nPerspective]; + final Offset offset = offsets[(i ~/ nPerspective) % nOffsets]; MatrixUtils.transformPoint(transform, offset); } watch.stop(); @@ -101,8 +101,8 @@ void main() { watch.reset(); watch.start(); for (int i = 0; i < _kNumIterations; i += 1) { - final Matrix4 transform = _affineTransforms[i % nAffine]; - final Offset offset = _offsets[(i ~/ nAffine) % nOffsets]; + final Matrix4 transform = affineTransforms[i % nAffine]; + final Offset offset = offsets[(i ~/ nAffine) % nOffsets]; MatrixUtils.transformPoint(transform, offset); } watch.stop(); diff --git a/dev/devicelab/lib/framework/browser.dart b/dev/devicelab/lib/framework/browser.dart index a28257c711..bd0c06efc0 100644 --- a/dev/devicelab/lib/framework/browser.dart +++ b/dev/devicelab/lib/framework/browser.dart @@ -351,7 +351,7 @@ class BlinkTraceSummary { averageBeginFrameTime: _computeAverageDuration(frames.map((BlinkFrame frame) => frame.beginFrame).whereType().toList()), averageUpdateLifecyclePhasesTime: _computeAverageDuration(frames.map((BlinkFrame frame) => frame.updateAllLifecyclePhases).whereType().toList()), ); - } catch (_, __) { + } catch (_) { final io.File traceFile = io.File('./chrome-trace.json'); io.stderr.writeln('Failed to interpret the Chrome trace contents. The trace was saved in ${traceFile.path}'); traceFile.writeAsStringSync(const JsonEncoder.withIndent(' ').convert(traceJson)); diff --git a/dev/devicelab/lib/tasks/gallery.dart b/dev/devicelab/lib/tasks/gallery.dart index fa5a69a449..bd7a49fee2 100644 --- a/dev/devicelab/lib/tasks/gallery.dart +++ b/dev/devicelab/lib/tasks/gallery.dart @@ -177,12 +177,12 @@ class GalleryTransitionTest { } int _countMissedTransitions(Map> transitions) { - const int _kTransitionBudget = 100000; // µs + const int kTransitionBudget = 100000; // µs int count = 0; transitions.forEach((String demoName, List durations) { final int longestDuration = durations.reduce(math.max); - if (longestDuration > _kTransitionBudget) { - print('$demoName missed transition time budget ($longestDuration µs > $_kTransitionBudget µs)'); + if (longestDuration > kTransitionBudget) { + print('$demoName missed transition time budget ($longestDuration µs > $kTransitionBudget µs)'); count++; } }); diff --git a/dev/devicelab/test/cocoon_test.dart b/dev/devicelab/test/cocoon_test.dart index 7e27e1ddc7..b0ac75ae97 100644 --- a/dev/devicelab/test/cocoon_test.dart +++ b/dev/devicelab/test/cocoon_test.dart @@ -16,7 +16,7 @@ import 'package:http/testing.dart'; import 'common.dart'; void main() { - late ProcessResult _processResult; + late ProcessResult processResult; ProcessResult runSyncStub(String executable, List args, {Map? environment, bool includeParentEnvironment = true, @@ -24,7 +24,7 @@ void main() { Encoding? stderrEncoding, Encoding? stdoutEncoding, String? workingDirectory}) => - _processResult; + processResult; // Expected test values. const String commitSha = 'a4952838bf288a81d8ea11edfd4b4cd649fa94cc'; @@ -45,7 +45,7 @@ void main() { }); test('returns expected commit sha', () { - _processResult = ProcessResult(1, 0, commitSha, ''); + processResult = ProcessResult(1, 0, commitSha, ''); cocoon = Cocoon( serviceAccountTokenPath: serviceAccountTokenPath, fs: fs, @@ -57,7 +57,7 @@ void main() { }); test('throws exception on git cli errors', () { - _processResult = ProcessResult(1, 1, '', ''); + processResult = ProcessResult(1, 1, '', ''); cocoon = Cocoon( serviceAccountTokenPath: serviceAccountTokenPath, fs: fs, @@ -69,7 +69,7 @@ void main() { }); test('writes expected update task json', () async { - _processResult = ProcessResult(1, 0, commitSha, ''); + processResult = ProcessResult(1, 0, commitSha, ''); final TaskResult result = TaskResult.fromJson({ 'success': true, 'data': { @@ -105,7 +105,7 @@ void main() { }); test('uploads metrics sends expected post body', () async { - _processResult = ProcessResult(1, 0, commitSha, ''); + processResult = ProcessResult(1, 0, commitSha, ''); const String uploadMetricsRequestWithSpaces = '{"CommitBranch":"master","CommitSha":"a4952838bf288a81d8ea11edfd4b4cd649fa94cc","BuilderName":"builder a b c","NewStatus":"Succeeded","ResultData":{},"BenchmarkScoreKeys":[],"TestFlaky":false}'; final MockClient client = MockClient((Request request) async { @@ -136,7 +136,7 @@ void main() { }); test('uploads expected update task payload from results file', () async { - _processResult = ProcessResult(1, 0, commitSha, ''); + processResult = ProcessResult(1, 0, commitSha, ''); cocoon = Cocoon( fs: fs, httpClient: mockClient, @@ -168,7 +168,7 @@ void main() { } }); - _processResult = ProcessResult(1, 0, commitSha, ''); + processResult = ProcessResult(1, 0, commitSha, ''); cocoon = Cocoon( fs: fs, httpClient: mockClient, @@ -202,7 +202,7 @@ void main() { } }); - _processResult = ProcessResult(1, 0, commitSha, ''); + processResult = ProcessResult(1, 0, commitSha, ''); cocoon = Cocoon( fs: fs, httpClient: mockClient, @@ -237,7 +237,7 @@ void main() { } }); - _processResult = ProcessResult(1, 0, commitSha, ''); + processResult = ProcessResult(1, 0, commitSha, ''); cocoon = Cocoon( fs: fs, httpClient: mockClient, @@ -270,7 +270,7 @@ void main() { } }); - _processResult = ProcessResult(1, 0, commitSha, ''); + processResult = ProcessResult(1, 0, commitSha, ''); cocoon = Cocoon( fs: fs, httpClient: mockClient, diff --git a/examples/api/lib/widgets/interactive_viewer/interactive_viewer.constrained.0.dart b/examples/api/lib/widgets/interactive_viewer/interactive_viewer.constrained.0.dart index c15ccedbfd..3dd5b6943c 100644 --- a/examples/api/lib/widgets/interactive_viewer/interactive_viewer.constrained.0.dart +++ b/examples/api/lib/widgets/interactive_viewer/interactive_viewer.constrained.0.dart @@ -30,8 +30,8 @@ class MyStatelessWidget extends StatelessWidget { @override Widget build(BuildContext context) { - const int _rowCount = 48; - const int _columnCount = 6; + const int rowCount = 48; + const int columnCount = 6; return InteractiveViewer( alignPanAxis: true, @@ -39,14 +39,14 @@ class MyStatelessWidget extends StatelessWidget { scaleEnabled: false, child: Table( columnWidths: { - for (int column = 0; column < _columnCount; column += 1) + for (int column = 0; column < columnCount; column += 1) column: const FixedColumnWidth(200.0), }, children: [ - for (int row = 0; row < _rowCount; row += 1) + for (int row = 0; row < rowCount; row += 1) TableRow( children: [ - for (int column = 0; column < _columnCount; column += 1) + for (int column = 0; column < columnCount; column += 1) Container( height: 26, color: row % 2 + column % 2 == 1 diff --git a/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view.0.dart b/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view.0.dart index 57bb9ca7af..14d616e8e4 100644 --- a/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view.0.dart +++ b/examples/api/lib/widgets/nested_scroll_view/nested_scroll_view.0.dart @@ -27,9 +27,9 @@ class MyStatelessWidget extends StatelessWidget { @override Widget build(BuildContext context) { - final List _tabs = ['Tab 1', 'Tab 2']; + final List tabs = ['Tab 1', 'Tab 2']; return DefaultTabController( - length: _tabs.length, // This is the number of tabs. + length: tabs.length, // This is the number of tabs. child: Scaffold( body: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { @@ -61,7 +61,7 @@ class MyStatelessWidget extends StatelessWidget { forceElevated: innerBoxIsScrolled, bottom: TabBar( // These are the widgets to put in each tab in the tab bar. - tabs: _tabs.map((String name) => Tab(text: name)).toList(), + tabs: tabs.map((String name) => Tab(text: name)).toList(), ), ), ), @@ -69,7 +69,7 @@ class MyStatelessWidget extends StatelessWidget { }, body: TabBarView( // These are the contents of the tab views, below the tabs. - children: _tabs.map((String name) { + children: tabs.map((String name) { return SafeArea( top: false, bottom: false, diff --git a/examples/api/lib/widgets/notification_listener/notification.0.dart b/examples/api/lib/widgets/notification_listener/notification.0.dart index 75c9083dc3..461a108e73 100644 --- a/examples/api/lib/widgets/notification_listener/notification.0.dart +++ b/examples/api/lib/widgets/notification_listener/notification.0.dart @@ -25,19 +25,20 @@ class MyApp extends StatelessWidget { class MyStatelessWidget extends StatelessWidget { const MyStatelessWidget({Key? key}) : super(key: key); + static const List _tabs = ['Months', 'Days']; + static const List _months = [ + 'January', + 'February', + 'March', + ]; + static const List _days = [ + 'Sunday', + 'Monday', + 'Tuesday', + ]; + @override Widget build(BuildContext context) { - const List _tabs = ['Months', 'Days']; - const List _months = [ - 'January', - 'February', - 'March', - ]; - const List _days = [ - 'Sunday', - 'Monday', - 'Tuesday', - ]; return DefaultTabController( length: _tabs.length, child: Scaffold( diff --git a/packages/flutter/lib/src/animation/animation_controller.dart b/packages/flutter/lib/src/animation/animation_controller.dart index 56ecbe9b79..da833d7828 100644 --- a/packages/flutter/lib/src/animation/animation_controller.dart +++ b/packages/flutter/lib/src/animation/animation_controller.dart @@ -898,9 +898,9 @@ class _RepeatingSimulation extends Simulation { final double totalTimeInSeconds = timeInSeconds + _initialT; final double t = (totalTimeInSeconds / _periodInSeconds) % 1.0; - final bool _isPlayingReverse = (totalTimeInSeconds ~/ _periodInSeconds).isOdd; + final bool isPlayingReverse = (totalTimeInSeconds ~/ _periodInSeconds).isOdd; - if (reverse && _isPlayingReverse) { + if (reverse && isPlayingReverse) { directionSetter(_AnimationDirection.reverse); return ui.lerpDouble(max, min, t)!; } else { diff --git a/packages/flutter/lib/src/cupertino/colors.dart b/packages/flutter/lib/src/cupertino/colors.dart index 52bc56572f..fc1e049b90 100644 --- a/packages/flutter/lib/src/cupertino/colors.dart +++ b/packages/flutter/lib/src/cupertino/colors.dart @@ -1003,9 +1003,9 @@ class CupertinoDynamicColor extends Color with Diagnosticable { } } - Element? _debugContext; + Element? debugContext; assert(() { - _debugContext = context as Element; + debugContext = context as Element; return true; }()); return CupertinoDynamicColor._( @@ -1018,7 +1018,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable { darkElevatedColor, highContrastElevatedColor, darkHighContrastElevatedColor, - _debugContext, + debugContext, _debugLabel, ); } diff --git a/packages/flutter/lib/src/cupertino/page_scaffold.dart b/packages/flutter/lib/src/cupertino/page_scaffold.dart index 3ad2a5a676..4aa597aa83 100644 --- a/packages/flutter/lib/src/cupertino/page_scaffold.dart +++ b/packages/flutter/lib/src/cupertino/page_scaffold.dart @@ -91,10 +91,10 @@ class CupertinoPageScaffold extends StatefulWidget { class _CupertinoPageScaffoldState extends State { void _handleStatusBarTap() { - final ScrollController? _primaryScrollController = PrimaryScrollController.of(context); + final ScrollController? primaryScrollController = PrimaryScrollController.of(context); // Only act on the scroll controller if it has any attached scroll positions. - if (_primaryScrollController != null && _primaryScrollController.hasClients) { - _primaryScrollController.animateTo( + if (primaryScrollController != null && primaryScrollController.hasClients) { + primaryScrollController.animateTo( 0.0, // Eyeballed from iOS. duration: const Duration(milliseconds: 500), diff --git a/packages/flutter/lib/src/cupertino/segmented_control.dart b/packages/flutter/lib/src/cupertino/segmented_control.dart index 5bc407eff2..c1260cf6f7 100644 --- a/packages/flutter/lib/src/cupertino/segmented_control.dart +++ b/packages/flutter/lib/src/cupertino/segmented_control.dart @@ -360,8 +360,8 @@ class _SegmentedControlState extends State _gestureChildren = []; - final List _backgroundColors = []; + final List gestureChildren = []; + final List backgroundColors = []; int index = 0; int? selectedIndex; int? pressedIndex; @@ -403,17 +403,17 @@ class _SegmentedControlState extends State( selectedIndex: selectedIndex, pressedIndex: pressedIndex, - backgroundColors: _backgroundColors, + backgroundColors: backgroundColors, borderColor: _borderColor!, - children: _gestureChildren, + children: gestureChildren, ); return Padding( diff --git a/packages/flutter/lib/src/foundation/_bitfield_io.dart b/packages/flutter/lib/src/foundation/_bitfield_io.dart index fac9a01712..cf29f7ead0 100644 --- a/packages/flutter/lib/src/foundation/_bitfield_io.dart +++ b/packages/flutter/lib/src/foundation/_bitfield_io.dart @@ -28,19 +28,19 @@ class BitField implements bitfield.BitField { @override bool operator [](T index) { - final int _index = index.index as int; - assert(_index < _length); - return (_bits & 1 << _index) > 0; + final int intIndex = index.index as int; + assert(intIndex < _length); + return (_bits & 1 << intIndex) > 0; } @override void operator []=(T index, bool value) { - final int _index = index.index as int; - assert(_index < _length); + final int intIndex = index.index as int; + assert(intIndex < _length); if (value) - _bits = _bits | (1 << _index); + _bits = _bits | (1 << intIndex); else - _bits = _bits & ~(1 << _index); + _bits = _bits & ~(1 << intIndex); } @override diff --git a/packages/flutter/lib/src/foundation/change_notifier.dart b/packages/flutter/lib/src/foundation/change_notifier.dart index a910f03e71..2775511bdb 100644 --- a/packages/flutter/lib/src/foundation/change_notifier.dart +++ b/packages/flutter/lib/src/foundation/change_notifier.dart @@ -232,8 +232,8 @@ class ChangeNotifier implements Listenable { void removeListener(VoidCallback listener) { assert(_debugAssertNotDisposed()); for (int i = 0; i < _count; i++) { - final VoidCallback? _listener = _listeners[i]; - if (_listener == listener) { + final VoidCallback? listenerAtIndex = _listeners[i]; + if (listenerAtIndex == listener) { if (_notificationCallStackDepth > 0) { // We don't resize the list during notifyListeners iterations // but we set to null, the listeners we want to remove. We will diff --git a/packages/flutter/lib/src/material/chip.dart b/packages/flutter/lib/src/material/chip.dart index 0a85fa313f..7537bf23d6 100644 --- a/packages/flutter/lib/src/material/chip.dart +++ b/packages/flutter/lib/src/material/chip.dart @@ -1855,7 +1855,7 @@ class _RawChipState extends State with MaterialStateMixin, TickerProvid /// gets closer to 2 the label padding is linearly interpolated from 8px to 4px. /// Once the widget has a text scaling of 2 or higher than the label padding /// remains 4px. - final EdgeInsetsGeometry _defaultLabelPadding = EdgeInsets.lerp( + final EdgeInsetsGeometry defaultLabelPadding = EdgeInsets.lerp( const EdgeInsets.symmetric(horizontal: 8.0), const EdgeInsets.symmetric(horizontal: 4.0), (MediaQuery.of(context).textScaleFactor - 1.0).clamp(0.0, 1.0), @@ -1905,7 +1905,7 @@ class _RawChipState extends State with MaterialStateMixin, TickerProvid final EdgeInsetsGeometry labelPadding = widget.labelPadding ?? chipTheme.labelPadding ?? theme.chipTheme.labelPadding - ?? _defaultLabelPadding; + ?? defaultLabelPadding; final TextStyle effectiveLabelStyle = labelStyle.merge(widget.labelStyle); final Color? resolvedLabelColor = MaterialStateProperty.resolveAs(effectiveLabelStyle.color, materialStates); diff --git a/packages/flutter/lib/src/material/list_tile.dart b/packages/flutter/lib/src/material/list_tile.dart index 71032f987b..706df9dd4a 100644 --- a/packages/flutter/lib/src/material/list_tile.dart +++ b/packages/flutter/lib/src/material/list_tile.dart @@ -1197,11 +1197,11 @@ class ListTile extends StatelessWidget { ); } - const EdgeInsets _defaultContentPadding = EdgeInsets.symmetric(horizontal: 16.0); + const EdgeInsets defaultContentPadding = EdgeInsets.symmetric(horizontal: 16.0); final TextDirection textDirection = Directionality.of(context); final EdgeInsets resolvedContentPadding = contentPadding?.resolve(textDirection) ?? tileTheme.contentPadding?.resolve(textDirection) - ?? _defaultContentPadding; + ?? defaultContentPadding; final MouseCursor resolvedMouseCursor = MaterialStateProperty.resolveAs( mouseCursor ?? MaterialStateMouseCursor.clickable, diff --git a/packages/flutter/lib/src/material/material_state_mixin.dart b/packages/flutter/lib/src/material/material_state_mixin.dart index de6743131f..9e8aadf45c 100644 --- a/packages/flutter/lib/src/material/material_state_mixin.dart +++ b/packages/flutter/lib/src/material/material_state_mixin.dart @@ -117,21 +117,21 @@ mixin MaterialStateMixin on State { /// Mutator to mark a [MaterialState] value as either active or inactive. @protected - void setMaterialState(MaterialState _state, bool isSet) { - return isSet ? addMaterialState(_state) : removeMaterialState(_state); + void setMaterialState(MaterialState state, bool isSet) { + return isSet ? addMaterialState(state) : removeMaterialState(state); } /// Mutator to mark a [MaterialState] value as active. @protected - void addMaterialState(MaterialState _state) { - if (materialStates.add(_state)) + void addMaterialState(MaterialState state) { + if (materialStates.add(state)) setState((){}); } /// Mutator to mark a [MaterialState] value as inactive. @protected - void removeMaterialState(MaterialState _state) { - if (materialStates.remove(_state)) + void removeMaterialState(MaterialState state) { + if (materialStates.remove(state)) setState((){}); } diff --git a/packages/flutter/lib/src/material/range_slider.dart b/packages/flutter/lib/src/material/range_slider.dart index 660d7615b0..10a253c02a 100644 --- a/packages/flutter/lib/src/material/range_slider.dart +++ b/packages/flutter/lib/src/material/range_slider.dart @@ -561,20 +561,20 @@ class _RangeSliderState extends State with TickerProviderStateMixin // the default shapes and text styles are aligned to the Material // Guidelines. - const double _defaultTrackHeight = 4; - const RangeSliderTrackShape _defaultTrackShape = RoundedRectRangeSliderTrackShape(); - const RangeSliderTickMarkShape _defaultTickMarkShape = RoundRangeSliderTickMarkShape(); - const SliderComponentShape _defaultOverlayShape = RoundSliderOverlayShape(); - const RangeSliderThumbShape _defaultThumbShape = RoundRangeSliderThumbShape(); - const RangeSliderValueIndicatorShape _defaultValueIndicatorShape = RectangularRangeSliderValueIndicatorShape(); - const ShowValueIndicator _defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete; - const double _defaultMinThumbSeparation = 8; + const double defaultTrackHeight = 4; + const RangeSliderTrackShape defaultTrackShape = RoundedRectRangeSliderTrackShape(); + const RangeSliderTickMarkShape defaultTickMarkShape = RoundRangeSliderTickMarkShape(); + const SliderComponentShape defaultOverlayShape = RoundSliderOverlayShape(); + const RangeSliderThumbShape defaultThumbShape = RoundRangeSliderThumbShape(); + const RangeSliderValueIndicatorShape defaultValueIndicatorShape = RectangularRangeSliderValueIndicatorShape(); + const ShowValueIndicator defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete; + const double defaultMinThumbSeparation = 8; // The value indicator's color is not the same as the thumb and active track // (which can be defined by activeColor) if the // RectangularSliderValueIndicatorShape is used. In all other cases, the // value indicator is assumed to be the same as the active color. - final RangeSliderValueIndicatorShape valueIndicatorShape = sliderTheme.rangeValueIndicatorShape ?? _defaultValueIndicatorShape; + final RangeSliderValueIndicatorShape valueIndicatorShape = sliderTheme.rangeValueIndicatorShape ?? defaultValueIndicatorShape; final Color valueIndicatorColor; if (valueIndicatorShape is RectangularRangeSliderValueIndicatorShape) { valueIndicatorColor = sliderTheme.valueIndicatorColor ?? Color.alphaBlend(theme.colorScheme.onSurface.withOpacity(0.60), theme.colorScheme.surface.withOpacity(0.90)); @@ -583,7 +583,7 @@ class _RangeSliderState extends State with TickerProviderStateMixin } sliderTheme = sliderTheme.copyWith( - trackHeight: sliderTheme.trackHeight ?? _defaultTrackHeight, + trackHeight: sliderTheme.trackHeight ?? defaultTrackHeight, activeTrackColor: widget.activeColor ?? sliderTheme.activeTrackColor ?? theme.colorScheme.primary, inactiveTrackColor: widget.inactiveColor ?? sliderTheme.inactiveTrackColor ?? theme.colorScheme.primary.withOpacity(0.24), disabledActiveTrackColor: sliderTheme.disabledActiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.32), @@ -597,16 +597,16 @@ class _RangeSliderState extends State with TickerProviderStateMixin disabledThumbColor: sliderTheme.disabledThumbColor ?? Color.alphaBlend(theme.colorScheme.onSurface.withOpacity(.38), theme.colorScheme.surface), overlayColor: widget.activeColor?.withOpacity(0.12) ?? sliderTheme.overlayColor ?? theme.colorScheme.primary.withOpacity(0.12), valueIndicatorColor: valueIndicatorColor, - rangeTrackShape: sliderTheme.rangeTrackShape ?? _defaultTrackShape, - rangeTickMarkShape: sliderTheme.rangeTickMarkShape ?? _defaultTickMarkShape, - rangeThumbShape: sliderTheme.rangeThumbShape ?? _defaultThumbShape, - overlayShape: sliderTheme.overlayShape ?? _defaultOverlayShape, + rangeTrackShape: sliderTheme.rangeTrackShape ?? defaultTrackShape, + rangeTickMarkShape: sliderTheme.rangeTickMarkShape ?? defaultTickMarkShape, + rangeThumbShape: sliderTheme.rangeThumbShape ?? defaultThumbShape, + overlayShape: sliderTheme.overlayShape ?? defaultOverlayShape, rangeValueIndicatorShape: valueIndicatorShape, - showValueIndicator: sliderTheme.showValueIndicator ?? _defaultShowValueIndicator, + showValueIndicator: sliderTheme.showValueIndicator ?? defaultShowValueIndicator, valueIndicatorTextStyle: sliderTheme.valueIndicatorTextStyle ?? theme.textTheme.bodyText1!.copyWith( color: theme.colorScheme.onPrimary, ), - minThumbSeparation: sliderTheme.minThumbSeparation ?? _defaultMinThumbSeparation, + minThumbSeparation: sliderTheme.minThumbSeparation ?? defaultMinThumbSeparation, thumbSelector: sliderTheme.thumbSelector ?? _defaultRangeThumbSelector, ); diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index fabb5c664b..5045c39147 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -2253,22 +2253,22 @@ class ScaffoldState extends State with TickerProviderStateMixin, Resto // will not be added to the Scaffold's appbar and the bottom sheet will not // support drag or swipe to dismiss. final AnimationController animationController = BottomSheet.createAnimationController(this)..value = 1.0; - LocalHistoryEntry? _persistentSheetHistoryEntry; + LocalHistoryEntry? persistentSheetHistoryEntry; bool _persistentBottomSheetExtentChanged(DraggableScrollableNotification notification) { if (notification.extent > notification.initialExtent) { - if (_persistentSheetHistoryEntry == null) { - _persistentSheetHistoryEntry = LocalHistoryEntry(onRemove: () { + if (persistentSheetHistoryEntry == null) { + persistentSheetHistoryEntry = LocalHistoryEntry(onRemove: () { if (notification.extent > notification.initialExtent) { DraggableScrollableActuator.reset(notification.context); } showBodyScrim(false, 0.0); _floatingActionButtonVisibilityValue = 1.0; - _persistentSheetHistoryEntry = null; + persistentSheetHistoryEntry = null; }); - ModalRoute.of(context)!.addLocalHistoryEntry(_persistentSheetHistoryEntry!); + ModalRoute.of(context)!.addLocalHistoryEntry(persistentSheetHistoryEntry!); } - } else if (_persistentSheetHistoryEntry != null) { - ModalRoute.of(context)!.removeLocalHistoryEntry(_persistentSheetHistoryEntry!); + } else if (persistentSheetHistoryEntry != null) { + ModalRoute.of(context)!.removeLocalHistoryEntry(persistentSheetHistoryEntry!); } return false; } @@ -2557,9 +2557,9 @@ class ScaffoldState extends State with TickerProviderStateMixin, Resto // top. We implement this by looking up the primary scroll controller and // scrolling it to the top when tapped. void _handleStatusBarTap() { - final ScrollController? _primaryScrollController = PrimaryScrollController.of(context); - if (_primaryScrollController != null && _primaryScrollController.hasClients) { - _primaryScrollController.animateTo( + final ScrollController? primaryScrollController = PrimaryScrollController.of(context); + if (primaryScrollController != null && primaryScrollController.hasClients) { + primaryScrollController.animateTo( 0.0, duration: const Duration(milliseconds: 300), curve: Curves.linear, // TODO(ianh): Use a more appropriate curve. @@ -2635,14 +2635,14 @@ class ScaffoldState extends State with TickerProviderStateMixin, Resto void didChangeDependencies() { // Using maybeOf is valid here since both the Scaffold and ScaffoldMessenger // are currently available for managing SnackBars. - final ScaffoldMessengerState? _currentScaffoldMessenger = ScaffoldMessenger.maybeOf(context); + final ScaffoldMessengerState? currentScaffoldMessenger = ScaffoldMessenger.maybeOf(context); // If our ScaffoldMessenger has changed, unregister with the old one first. if (_scaffoldMessenger != null && - (_currentScaffoldMessenger == null || _scaffoldMessenger != _currentScaffoldMessenger)) { + (currentScaffoldMessenger == null || _scaffoldMessenger != currentScaffoldMessenger)) { _scaffoldMessenger?._unregister(this); } // Register with the current ScaffoldMessenger, if there is one. - _scaffoldMessenger = _currentScaffoldMessenger; + _scaffoldMessenger = currentScaffoldMessenger; _scaffoldMessenger?._register(this); // TODO(Piinks): Remove old SnackBar API after migrating ScaffoldMessenger @@ -3064,7 +3064,7 @@ class ScaffoldState extends State with TickerProviderStateMixin, Resto ); // extendBody locked when keyboard is open - final bool _extendBody = minInsets.bottom <= 0 && widget.extendBody; + final bool extendBody = minInsets.bottom <= 0 && widget.extendBody; return _ScaffoldScope( hasDrawer: hasDrawer, @@ -3075,7 +3075,7 @@ class ScaffoldState extends State with TickerProviderStateMixin, Resto child: AnimatedBuilder(animation: _floatingActionButtonMoveController, builder: (BuildContext context, Widget? child) { return CustomMultiChildLayout( delegate: _ScaffoldLayout( - extendBody: _extendBody, + extendBody: extendBody, extendBodyBehindAppBar: widget.extendBodyBehindAppBar, minInsets: minInsets, minViewPadding: minViewPadding, diff --git a/packages/flutter/lib/src/material/slider.dart b/packages/flutter/lib/src/material/slider.dart index 6b21f6d931..39f75a5136 100644 --- a/packages/flutter/lib/src/material/slider.dart +++ b/packages/flutter/lib/src/material/slider.dart @@ -659,19 +659,19 @@ class _SliderState extends State with TickerProviderStateMixin { // the default shapes and text styles are aligned to the Material // Guidelines. - const double _defaultTrackHeight = 4; - const SliderTrackShape _defaultTrackShape = RoundedRectSliderTrackShape(); - const SliderTickMarkShape _defaultTickMarkShape = RoundSliderTickMarkShape(); - const SliderComponentShape _defaultOverlayShape = RoundSliderOverlayShape(); - const SliderComponentShape _defaultThumbShape = RoundSliderThumbShape(); - const SliderComponentShape _defaultValueIndicatorShape = RectangularSliderValueIndicatorShape(); - const ShowValueIndicator _defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete; + const double defaultTrackHeight = 4; + const SliderTrackShape defaultTrackShape = RoundedRectSliderTrackShape(); + const SliderTickMarkShape defaultTickMarkShape = RoundSliderTickMarkShape(); + const SliderComponentShape defaultOverlayShape = RoundSliderOverlayShape(); + const SliderComponentShape defaultThumbShape = RoundSliderThumbShape(); + const SliderComponentShape defaultValueIndicatorShape = RectangularSliderValueIndicatorShape(); + const ShowValueIndicator defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete; // The value indicator's color is not the same as the thumb and active track // (which can be defined by activeColor) if the // RectangularSliderValueIndicatorShape is used. In all other cases, the // value indicator is assumed to be the same as the active color. - final SliderComponentShape valueIndicatorShape = sliderTheme.valueIndicatorShape ?? _defaultValueIndicatorShape; + final SliderComponentShape valueIndicatorShape = sliderTheme.valueIndicatorShape ?? defaultValueIndicatorShape; final Color valueIndicatorColor; if (valueIndicatorShape is RectangularSliderValueIndicatorShape) { valueIndicatorColor = sliderTheme.valueIndicatorColor ?? Color.alphaBlend(theme.colorScheme.onSurface.withOpacity(0.60), theme.colorScheme.surface.withOpacity(0.90)); @@ -680,7 +680,7 @@ class _SliderState extends State with TickerProviderStateMixin { } sliderTheme = sliderTheme.copyWith( - trackHeight: sliderTheme.trackHeight ?? _defaultTrackHeight, + trackHeight: sliderTheme.trackHeight ?? defaultTrackHeight, activeTrackColor: widget.activeColor ?? sliderTheme.activeTrackColor ?? theme.colorScheme.primary, inactiveTrackColor: widget.inactiveColor ?? sliderTheme.inactiveTrackColor ?? theme.colorScheme.primary.withOpacity(0.24), disabledActiveTrackColor: sliderTheme.disabledActiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.32), @@ -693,12 +693,12 @@ class _SliderState extends State with TickerProviderStateMixin { disabledThumbColor: sliderTheme.disabledThumbColor ?? Color.alphaBlend(theme.colorScheme.onSurface.withOpacity(.38), theme.colorScheme.surface), overlayColor: widget.activeColor?.withOpacity(0.12) ?? sliderTheme.overlayColor ?? theme.colorScheme.primary.withOpacity(0.12), valueIndicatorColor: valueIndicatorColor, - trackShape: sliderTheme.trackShape ?? _defaultTrackShape, - tickMarkShape: sliderTheme.tickMarkShape ?? _defaultTickMarkShape, - thumbShape: sliderTheme.thumbShape ?? _defaultThumbShape, - overlayShape: sliderTheme.overlayShape ?? _defaultOverlayShape, + trackShape: sliderTheme.trackShape ?? defaultTrackShape, + tickMarkShape: sliderTheme.tickMarkShape ?? defaultTickMarkShape, + thumbShape: sliderTheme.thumbShape ?? defaultThumbShape, + overlayShape: sliderTheme.overlayShape ?? defaultOverlayShape, valueIndicatorShape: valueIndicatorShape, - showValueIndicator: sliderTheme.showValueIndicator ?? _defaultShowValueIndicator, + showValueIndicator: sliderTheme.showValueIndicator ?? defaultShowValueIndicator, valueIndicatorTextStyle: sliderTheme.valueIndicatorTextStyle ?? theme.textTheme.bodyText1!.copyWith( color: theme.colorScheme.onPrimary, ), diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index 6a40f3d93d..418f1a2f20 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -413,10 +413,10 @@ class ThemeData with Diagnosticable { assert(colorSchemeSeed == null || colorScheme == null); assert(colorSchemeSeed == null || primarySwatch == null); assert(colorSchemeSeed == null || primaryColor == null); - final Brightness _brightness = brightness ?? colorScheme?.brightness ?? Brightness.light; - final bool isDark = _brightness == Brightness.dark; + final Brightness effectiveBrightness = brightness ?? colorScheme?.brightness ?? Brightness.light; + final bool isDark = effectiveBrightness == Brightness.dark; if (colorSchemeSeed != null) { - colorScheme = ColorScheme.fromSeed(seedColor: colorSchemeSeed, brightness: _brightness); + colorScheme = ColorScheme.fromSeed(seedColor: colorSchemeSeed, brightness: effectiveBrightness); // For surfaces that use primary color in light themes and surface color in dark final Color primarySurfaceColor = isDark ? colorScheme.surface : colorScheme.primary; @@ -441,10 +441,10 @@ class ThemeData with Diagnosticable { applyElevationOverlayColor ??= false; primarySwatch ??= Colors.blue; primaryColor ??= isDark ? Colors.grey[900]! : primarySwatch; - final Brightness _primaryColorBrightness = estimateBrightnessForColor(primaryColor); + final Brightness estimatedPrimaryColorBrightness = estimateBrightnessForColor(primaryColor); primaryColorLight ??= isDark ? Colors.grey[500]! : primarySwatch[100]!; primaryColorDark ??= isDark ? Colors.black : primarySwatch[700]!; - final bool primaryIsDark = _primaryColorBrightness == Brightness.dark; + final bool primaryIsDark = estimatedPrimaryColorBrightness == Brightness.dark; toggleableActiveColor ??= isDark ? Colors.tealAccent[200]! : (accentColor ?? primarySwatch[600]!); accentColor ??= isDark ? Colors.tealAccent[200]! : primarySwatch[500]!; accentColorBrightness ??= estimateBrightnessForColor(accentColor); @@ -466,7 +466,7 @@ class ThemeData with Diagnosticable { cardColor: cardColor, backgroundColor: backgroundColor, errorColor: errorColor, - brightness: _brightness, + brightness: effectiveBrightness, ); selectedRowColor ??= Colors.grey[100]!; unselectedWidgetColor ??= isDark ? Colors.white70 : Colors.black54; @@ -551,7 +551,7 @@ class ThemeData with Diagnosticable { accentIconTheme ??= accentIsDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black); buttonColor ??= isDark ? primarySwatch[600]! : Colors.grey[300]!; fixTextFieldOutlineLabel ??= true; - primaryColorBrightness = _primaryColorBrightness; + primaryColorBrightness = estimatedPrimaryColorBrightness; return ThemeData.raw( // GENERAL CONFIGURATION diff --git a/packages/flutter/lib/src/material/time_picker.dart b/packages/flutter/lib/src/material/time_picker.dart index 31377f3168..9edee70689 100644 --- a/packages/flutter/lib/src/material/time_picker.dart +++ b/packages/flutter/lib/src/material/time_picker.dart @@ -1203,7 +1203,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { ]; List<_TappableLabel> _buildMinutes(TextTheme textTheme, Color color) { - const List _minuteMarkerValues = [ + const List minuteMarkerValues = [ TimeOfDay(hour: 0, minute: 0), TimeOfDay(hour: 0, minute: 5), TimeOfDay(hour: 0, minute: 10), @@ -1219,7 +1219,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { ]; return <_TappableLabel>[ - for (final TimeOfDay timeOfDay in _minuteMarkerValues) + for (final TimeOfDay timeOfDay in minuteMarkerValues) _buildTappableLabel( textTheme, color, diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart index 1687ce1522..165e81281f 100644 --- a/packages/flutter/lib/src/rendering/box.dart +++ b/packages/flutter/lib/src/rendering/box.dart @@ -1981,14 +1981,14 @@ abstract class RenderBox extends RenderObject { Size get size { assert(hasSize, 'RenderBox was not laid out: ${toString()}'); assert(() { - final Size? _size = this._size; - if (_size is _DebugSize) { - assert(_size._owner == this); + final Size? size = _size; + if (size is _DebugSize) { + assert(size._owner == this); if (RenderObject.debugActiveLayout != null && !RenderObject.debugActiveLayout!.debugDoingThisLayoutWithCallback) { assert( debugDoingThisResize || debugDoingThisLayout || _computingThisDryLayout || - (RenderObject.debugActiveLayout == parent && _size._canBeUsedByParent), + (RenderObject.debugActiveLayout == parent && size._canBeUsedByParent), 'RenderBox.size accessed beyond the scope of resize, layout, or ' 'permitted parent access. RenderBox can always access its own size, ' 'otherwise, the only object that is allowed to read RenderBox.size ' @@ -1997,7 +1997,7 @@ abstract class RenderBox extends RenderObject { "that child's layout().", ); } - assert(_size == this._size); + assert(size == _size); } return true; }()); diff --git a/packages/flutter/lib/src/rendering/object.dart b/packages/flutter/lib/src/rendering/object.dart index b42ae2d983..bc6923f347 100644 --- a/packages/flutter/lib/src/rendering/object.dart +++ b/packages/flutter/lib/src/rendering/object.dart @@ -3300,8 +3300,8 @@ mixin ContainerRenderObjectMixin _parseLicenses(String rawLicenses) { - final String _licenseSeparator = '\n${'-' * 80}\n'; + final String licenseSeparator = '\n${'-' * 80}\n'; final List result = []; - final List licenses = rawLicenses.split(_licenseSeparator); + final List licenses = rawLicenses.split(licenseSeparator); for (final String license in licenses) { final int split = license.indexOf('\n\n'); if (split >= 0) { diff --git a/packages/flutter/lib/src/services/keyboard_key.dart b/packages/flutter/lib/src/services/keyboard_key.dart index ff76e1f724..ca3b4232ec 100644 --- a/packages/flutter/lib/src/services/keyboard_key.dart +++ b/packages/flutter/lib/src/services/keyboard_key.dart @@ -83,9 +83,9 @@ class LogicalKeyboardKey extends KeyboardKey { const int valueMaskWidth = 32; // Equivalent to assert(divisorForValueMask == (1 << valueMaskWidth)). - const int _firstDivisorWidth = 28; + const int firstDivisorWidth = 28; assert(divisorForValueMask == - (1 << _firstDivisorWidth) * (1 << (valueMaskWidth - _firstDivisorWidth))); + (1 << firstDivisorWidth) * (1 << (valueMaskWidth - firstDivisorWidth))); // JS only supports up to 2^53 - 1, therefore non-value bits can only // contain (maxSafeIntegerWidth - valueMaskWidth) bits. diff --git a/packages/flutter/lib/src/widgets/nested_scroll_view.dart b/packages/flutter/lib/src/widgets/nested_scroll_view.dart index a44118b9bc..b169f93c7d 100644 --- a/packages/flutter/lib/src/widgets/nested_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/nested_scroll_view.dart @@ -428,7 +428,7 @@ class NestedScrollViewState extends State { @override Widget build(BuildContext context) { - final ScrollPhysics _scrollPhysics = widget.physics?.applyTo(const ClampingScrollPhysics()) + final ScrollPhysics scrollPhysics = widget.physics?.applyTo(const ClampingScrollPhysics()) ?? widget.scrollBehavior?.getScrollPhysics(context).applyTo(const ClampingScrollPhysics()) ?? const ClampingScrollPhysics(); @@ -441,7 +441,7 @@ class NestedScrollViewState extends State { dragStartBehavior: widget.dragStartBehavior, scrollDirection: widget.scrollDirection, reverse: widget.reverse, - physics: _scrollPhysics, + physics: scrollPhysics, scrollBehavior: widget.scrollBehavior ?? ScrollConfiguration.of(context).copyWith(scrollbars: false), controller: _coordinator!._outerController, slivers: widget._buildSlivers( diff --git a/packages/flutter/lib/src/widgets/restoration_properties.dart b/packages/flutter/lib/src/widgets/restoration_properties.dart index 86755fb94f..03740b4c51 100644 --- a/packages/flutter/lib/src/widgets/restoration_properties.dart +++ b/packages/flutter/lib/src/widgets/restoration_properties.dart @@ -135,10 +135,10 @@ class _RestorablePrimitiveValueN extends RestorableValue { // _RestorablePrimitiveValue and its subclasses are non-nullable. // See [_RestorablePrimitiveValueN] for the nullable version of this class. class _RestorablePrimitiveValue extends _RestorablePrimitiveValueN { - _RestorablePrimitiveValue(T _defaultValue) - : assert(_defaultValue != null), - assert(debugIsSerializableForRestoration(_defaultValue)), - super(_defaultValue); + _RestorablePrimitiveValue(T defaultValue) + : assert(defaultValue != null), + assert(debugIsSerializableForRestoration(defaultValue)), + super(defaultValue); @override set value(T value) { diff --git a/packages/flutter/test/cupertino/context_menu_action_test.dart b/packages/flutter/test/cupertino/context_menu_action_test.dart index 00d75f32fc..f8ed139c8b 100644 --- a/packages/flutter/test/cupertino/context_menu_action_test.dart +++ b/packages/flutter/test/cupertino/context_menu_action_test.dart @@ -9,17 +9,16 @@ import '../rendering/mock_canvas.dart'; void main() { // Constants taken from _ContextMenuActionState. - const CupertinoDynamicColor _kBackgroundColor = CupertinoDynamicColor.withBrightness( + const CupertinoDynamicColor kBackgroundColor = CupertinoDynamicColor.withBrightness( color: Color(0xFFEEEEEE), darkColor: Color(0xFF212122), ); - // static const Color _kBackgroundColorPressed = Color(0xFFDDDDDD); - const CupertinoDynamicColor _kBackgroundColorPressed = CupertinoDynamicColor.withBrightness( + const CupertinoDynamicColor kBackgroundColorPressed = CupertinoDynamicColor.withBrightness( color: Color(0xFFDDDDDD), darkColor: Color(0xFF3F3F40), ); - const Color _kDestructiveActionColor = CupertinoColors.destructiveRed; - const FontWeight _kDefaultActionWeight = FontWeight.w600; + const Color kDestructiveActionColor = CupertinoColors.destructiveRed; + const FontWeight kDefaultActionWeight = FontWeight.w600; Widget _getApp({ VoidCallback? onPressed, @@ -82,28 +81,28 @@ void main() { testWidgets('turns grey when pressed and held', (WidgetTester tester) async { await tester.pumpWidget(_getApp()); - expect(find.byType(CupertinoContextMenuAction), paints..rect(color: _kBackgroundColor.color)); + expect(find.byType(CupertinoContextMenuAction), paints..rect(color: kBackgroundColor.color)); final Offset actionCenterLight = tester.getCenter(find.byType(CupertinoContextMenuAction)); final TestGesture gestureLight = await tester.startGesture(actionCenterLight); await tester.pump(); - expect(find.byType(CupertinoContextMenuAction), paints..rect(color: _kBackgroundColorPressed.color)); + expect(find.byType(CupertinoContextMenuAction), paints..rect(color: kBackgroundColorPressed.color)); await gestureLight.up(); await tester.pump(); - expect(find.byType(CupertinoContextMenuAction), paints..rect(color: _kBackgroundColor.color)); + expect(find.byType(CupertinoContextMenuAction), paints..rect(color: kBackgroundColor.color)); await tester.pumpWidget(_getApp(brightness: Brightness.dark)); - expect(find.byType(CupertinoContextMenuAction), paints..rect(color: _kBackgroundColor.darkColor)); + expect(find.byType(CupertinoContextMenuAction), paints..rect(color: kBackgroundColor.darkColor)); final Offset actionCenterDark = tester.getCenter(find.byType(CupertinoContextMenuAction)); final TestGesture gestureDark = await tester.startGesture(actionCenterDark); await tester.pump(); - expect(find.byType(CupertinoContextMenuAction), paints..rect(color: _kBackgroundColorPressed.darkColor)); + expect(find.byType(CupertinoContextMenuAction), paints..rect(color: kBackgroundColorPressed.darkColor)); await gestureDark.up(); await tester.pump(); - expect(find.byType(CupertinoContextMenuAction), paints..rect(color: _kBackgroundColor.darkColor)); + expect(find.byType(CupertinoContextMenuAction), paints..rect(color: kBackgroundColor.darkColor)); }); testWidgets('icon and textStyle colors are correct out of the box', (WidgetTester tester) async { @@ -114,13 +113,13 @@ void main() { testWidgets('icon and textStyle colors are correct for destructive actions', (WidgetTester tester) async { await tester.pumpWidget(_getApp(isDestructiveAction: true)); - expect(_getTextStyle(tester).color, _kDestructiveActionColor); - expect(_getIcon(tester).color, _kDestructiveActionColor); + expect(_getTextStyle(tester).color, kDestructiveActionColor); + expect(_getIcon(tester).color, kDestructiveActionColor); }); testWidgets('textStyle is correct for defaultAction', (WidgetTester tester) async { await tester.pumpWidget(_getApp(isDefaultAction: true)); - expect(_getTextStyle(tester).fontWeight, _kDefaultActionWeight); + expect(_getTextStyle(tester).fontWeight, kDefaultActionWeight); }); } diff --git a/packages/flutter/test/cupertino/context_menu_test.dart b/packages/flutter/test/cupertino/context_menu_test.dart index ffb0011778..9512c513ae 100644 --- a/packages/flutter/test/cupertino/context_menu_test.dart +++ b/packages/flutter/test/cupertino/context_menu_test.dart @@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding; - const double _kOpenScale = 1.1; + const double kOpenScale = 1.1; Widget _getChild() { return Container( width: 300.0, @@ -120,7 +120,7 @@ void main() { await tester.pump(const Duration(milliseconds: 500)); decoyChildRect = tester.getRect(_findDecoyChild(child)); expect(childRect, isNot(equals(decoyChildRect))); - expect(decoyChildRect.width, childRect.width * _kOpenScale); + expect(decoyChildRect.width, childRect.width * kOpenScale); // Then the CupertinoContextMenu opens. await tester.pumpAndSettle(); @@ -185,7 +185,7 @@ void main() { await tester.pump(const Duration(milliseconds: 500)); decoyChildRect = tester.getRect(_findDecoyChild(child)); expect(childRect, isNot(equals(decoyChildRect))); - expect(decoyChildRect.width, childRect.width * _kOpenScale); + expect(decoyChildRect.width, childRect.width * kOpenScale); // Then the CupertinoContextMenu opens. await tester.pumpAndSettle(); diff --git a/packages/flutter/test/cupertino/route_test.dart b/packages/flutter/test/cupertino/route_test.dart index 1d70902512..6803d95a5a 100644 --- a/packages/flutter/test/cupertino/route_test.dart +++ b/packages/flutter/test/cupertino/route_test.dart @@ -1543,7 +1543,7 @@ void main() { }); testWidgets('showCupertinoModalPopup transparent barrier color is transparent', (WidgetTester tester) async { - const Color _kTransparentColor = Color(0x00000000); + const Color kTransparentColor = Color(0x00000000); await tester.pumpWidget(CupertinoApp( home: CupertinoPageScaffold( @@ -1553,7 +1553,7 @@ void main() { await showCupertinoModalPopup( context: context, builder: (BuildContext context) => const SizedBox(), - barrierColor: _kTransparentColor, + barrierColor: kTransparentColor, ); }, child: const Text('tap'), diff --git a/packages/flutter/test/cupertino/scrollbar_test.dart b/packages/flutter/test/cupertino/scrollbar_test.dart index dbc017a30a..5e1f0efc9c 100644 --- a/packages/flutter/test/cupertino/scrollbar_test.dart +++ b/packages/flutter/test/cupertino/scrollbar_test.dart @@ -17,10 +17,10 @@ const CupertinoDynamicColor _kScrollbarColor = CupertinoDynamicColor.withBrightn ); void main() { - const Duration _kScrollbarTimeToFade = Duration(milliseconds: 1200); - const Duration _kScrollbarFadeDuration = Duration(milliseconds: 250); - const Duration _kScrollbarResizeDuration = Duration(milliseconds: 100); - const Duration _kLongPressDuration = Duration(milliseconds: 100); + const Duration kScrollbarTimeToFade = Duration(milliseconds: 1200); + const Duration kScrollbarFadeDuration = Duration(milliseconds: 250); + const Duration kScrollbarResizeDuration = Duration(milliseconds: 100); + const Duration kLongPressDuration = Duration(milliseconds: 100); testWidgets('Scrollbar never goes away until finger lift', (WidgetTester tester) async { await tester.pumpWidget( @@ -51,8 +51,8 @@ void main() { )); await gesture.up(); - await tester.pump(_kScrollbarTimeToFade); - await tester.pump(_kScrollbarFadeDuration * 0.5); + await tester.pump(kScrollbarTimeToFade); + await tester.pump(kScrollbarFadeDuration * 0.5); // Opacity going down now. expect(find.byType(CupertinoScrollbar), paints..rrect( @@ -143,9 +143,9 @@ void main() { // Long press on the scrollbar thumb and expect a vibration after it resizes. expect(hapticFeedbackCalls, 0); final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(796.0, 50.0)); - await tester.pump(_kLongPressDuration); + await tester.pump(kLongPressDuration); expect(hapticFeedbackCalls, 0); - await tester.pump(_kScrollbarResizeDuration); + await tester.pump(kScrollbarResizeDuration); // Allow the haptic feedback some slack. await tester.pump(const Duration(milliseconds: 1)); expect(hapticFeedbackCalls, 1); @@ -165,8 +165,8 @@ void main() { )); // Let the thumb fade out so all timers have resolved. - await tester.pump(_kScrollbarTimeToFade); - await tester.pump(_kScrollbarFadeDuration); + await tester.pump(kScrollbarTimeToFade); + await tester.pump(kScrollbarFadeDuration); }); testWidgets('Scrollbar thumb can be dragged with long press - reverse', (WidgetTester tester) async { @@ -217,9 +217,9 @@ void main() { // Long press on the scrollbar thumb and expect a vibration after it resizes. expect(hapticFeedbackCalls, 0); final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(796.0, 550.0)); - await tester.pump(_kLongPressDuration); + await tester.pump(kLongPressDuration); expect(hapticFeedbackCalls, 0); - await tester.pump(_kScrollbarResizeDuration); + await tester.pump(kScrollbarResizeDuration); // Allow the haptic feedback some slack. await tester.pump(const Duration(milliseconds: 1)); expect(hapticFeedbackCalls, 1); @@ -239,8 +239,8 @@ void main() { )); // Let the thumb fade out so all timers have resolved. - await tester.pump(_kScrollbarTimeToFade); - await tester.pump(_kScrollbarFadeDuration); + await tester.pump(kScrollbarTimeToFade); + await tester.pump(kScrollbarFadeDuration); }); testWidgets('Scrollbar changes thickness and radius when dragged', (WidgetTester tester) async { @@ -294,7 +294,7 @@ void main() { // Long press on the scrollbar thumb and expect it to grow final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(780.0, 50.0)); - await tester.pump(_kLongPressDuration); + await tester.pump(kLongPressDuration); expect(find.byType(CupertinoScrollbar), paints..rrect( rrect: RRect.fromRectAndRadius( Rect.fromLTWH( @@ -306,7 +306,7 @@ void main() { const Radius.circular(radius), ), )); - await tester.pump(_kScrollbarResizeDuration ~/ 2); + await tester.pump(kScrollbarResizeDuration ~/ 2); const double midpointThickness = (thickness + thicknessWhileDragging) / 2; const double midpointRadius = (radius + radiusWhileDragging) / 2; expect(find.byType(CupertinoScrollbar), paints..rrect( @@ -320,7 +320,7 @@ void main() { const Radius.circular(midpointRadius), ), )); - await tester.pump(_kScrollbarResizeDuration ~/ 2); + await tester.pump(kScrollbarResizeDuration ~/ 2); expect(find.byType(CupertinoScrollbar), paints..rrect( rrect: RRect.fromRectAndRadius( Rect.fromLTWH( @@ -336,8 +336,8 @@ void main() { // Let the thumb fade out so all timers have resolved. await dragScrollbarGesture.up(); await tester.pumpAndSettle(); - await tester.pump(_kScrollbarTimeToFade); - await tester.pump(_kScrollbarFadeDuration); + await tester.pump(kScrollbarTimeToFade); + await tester.pump(kScrollbarFadeDuration); }); testWidgets( @@ -674,7 +674,7 @@ void main() { expect(find.byType(CupertinoScrollbar), paints..rrect()); // Wait for the timer delay to expire. - await tester.pump(const Duration(milliseconds: 600)); // _kScrollbarTimeToFade + await tester.pump(const Duration(milliseconds: 600)); // kScrollbarTimeToFade await tester.pumpAndSettle(); // Scrollbar thumb is showing after scroll finishes and timer ends. expect(find.byType(CupertinoScrollbar), paints..rrect()); @@ -784,9 +784,9 @@ void main() { // Long press on the scrollbar thumb and expect a vibration after it resizes. expect(hapticFeedbackCalls, 0); final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(50.0, 596.0)); - await tester.pump(_kLongPressDuration); + await tester.pump(kLongPressDuration); expect(hapticFeedbackCalls, 0); - await tester.pump(_kScrollbarResizeDuration); + await tester.pump(kScrollbarResizeDuration); // Allow the haptic feedback some slack. await tester.pump(const Duration(milliseconds: 1)); expect(hapticFeedbackCalls, 1); @@ -806,8 +806,8 @@ void main() { )); // Let the thumb fade out so all timers have resolved. - await tester.pump(_kScrollbarTimeToFade); - await tester.pump(_kScrollbarFadeDuration); + await tester.pump(kScrollbarTimeToFade); + await tester.pump(kScrollbarFadeDuration); }); testWidgets('Scrollbar thumb can be dragged with long press - horizontal axis, reverse', (WidgetTester tester) async { @@ -858,9 +858,9 @@ void main() { // Long press on the scrollbar thumb and expect a vibration after it resizes. expect(hapticFeedbackCalls, 0); final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(750.0, 596.0)); - await tester.pump(_kLongPressDuration); + await tester.pump(kLongPressDuration); expect(hapticFeedbackCalls, 0); - await tester.pump(_kScrollbarResizeDuration); + await tester.pump(kScrollbarResizeDuration); // Allow the haptic feedback some slack. await tester.pump(const Duration(milliseconds: 1)); expect(hapticFeedbackCalls, 1); @@ -880,8 +880,8 @@ void main() { )); // Let the thumb fade out so all timers have resolved. - await tester.pump(_kScrollbarTimeToFade); - await tester.pump(_kScrollbarFadeDuration); + await tester.pump(kScrollbarTimeToFade); + await tester.pump(kScrollbarFadeDuration); }); testWidgets('Tapping the track area pages the Scroll View', (WidgetTester tester) async { @@ -1015,8 +1015,8 @@ void main() { ), ); final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(796.0, 50.0)); - await tester.pump(_kLongPressDuration); - await tester.pump(_kScrollbarResizeDuration); + await tester.pump(kLongPressDuration); + await tester.pump(kScrollbarResizeDuration); // Drag the thumb down to scroll down. await dragScrollbarGesture.moveBy(const Offset(0.0, scrollAmount)); diff --git a/packages/flutter/test/cupertino/text_form_field_row_test.dart b/packages/flutter/test/cupertino/text_form_field_row_test.dart index 9445afd4e9..830431848e 100644 --- a/packages/flutter/test/cupertino/text_form_field_row_test.dart +++ b/packages/flutter/test/cupertino/text_form_field_row_test.dart @@ -136,14 +136,14 @@ void main() { }); testWidgets('onFieldSubmit callbacks are called', (WidgetTester tester) async { - bool _called = false; + bool called = false; await tester.pumpWidget( CupertinoApp( home: Center( child: CupertinoTextFormFieldRow( onFieldSubmitted: (String value) { - _called = true; + called = true; }, ), ), @@ -153,18 +153,18 @@ void main() { await tester.showKeyboard(find.byType(CupertinoTextField)); await tester.testTextInput.receiveAction(TextInputAction.done); await tester.pump(); - expect(_called, true); + expect(called, true); }); testWidgets('onChanged callbacks are called', (WidgetTester tester) async { - late String _value; + late String value; await tester.pumpWidget( CupertinoApp( home: Center( child: CupertinoTextFormFieldRow( - onChanged: (String value) { - _value = value; + onChanged: (String v) { + value = v; }, ), ), @@ -173,11 +173,11 @@ void main() { await tester.enterText(find.byType(CupertinoTextField), 'Soup'); await tester.pump(); - expect(_value, 'Soup'); + expect(value, 'Soup'); }); testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async { - int _validateCalled = 0; + int validateCalled = 0; await tester.pumpWidget( CupertinoApp( @@ -185,7 +185,7 @@ void main() { child: CupertinoTextFormFieldRow( autovalidateMode: AutovalidateMode.always, validator: (String? value) { - _validateCalled++; + validateCalled++; return null; }, ), @@ -193,14 +193,14 @@ void main() { ), ); - expect(_validateCalled, 1); + expect(validateCalled, 1); await tester.enterText(find.byType(CupertinoTextField), 'a'); await tester.pump(); - expect(_validateCalled, 2); + expect(validateCalled, 2); }); testWidgets('validate is called if widget is enabled', (WidgetTester tester) async { - int _validateCalled = 0; + int validateCalled = 0; await tester.pumpWidget( CupertinoApp( @@ -209,7 +209,7 @@ void main() { enabled: true, autovalidateMode: AutovalidateMode.always, validator: (String? value) { - _validateCalled += 1; + validateCalled += 1; return null; }, ), @@ -217,10 +217,10 @@ void main() { ), ); - expect(_validateCalled, 1); + expect(validateCalled, 1); await tester.enterText(find.byType(CupertinoTextField), 'a'); await tester.pump(); - expect(_validateCalled, 2); + expect(validateCalled, 2); }); testWidgets('readonly text form field will hide cursor by default', (WidgetTester tester) async { @@ -329,7 +329,7 @@ void main() { }); testWidgets('onChanged callbacks value and FormFieldState.value are sync', (WidgetTester tester) async { - bool _called = false; + bool called = false; late FormFieldState state; @@ -338,7 +338,7 @@ void main() { home: Center( child: CupertinoTextFormFieldRow( onChanged: (String value) { - _called = true; + called = true; expect(value, state.value); }, ), @@ -351,7 +351,7 @@ void main() { await tester.enterText(find.byType(CupertinoTextField), 'Soup'); - expect(_called, true); + expect(called, true); }); testWidgets('autofillHints is passed to super', (WidgetTester tester) async { @@ -371,7 +371,7 @@ void main() { }); testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async { - int _validateCalled = 0; + int validateCalled = 0; await tester.pumpWidget( CupertinoApp( @@ -379,7 +379,7 @@ void main() { child: CupertinoTextFormFieldRow( autovalidateMode: AutovalidateMode.onUserInteraction, validator: (String? value) { - _validateCalled++; + validateCalled++; return null; }, ), @@ -387,10 +387,10 @@ void main() { ), ); - expect(_validateCalled, 0); + expect(validateCalled, 0); await tester.enterText(find.byType(CupertinoTextField), 'a'); await tester.pump(); - expect(_validateCalled, 1); + expect(validateCalled, 1); }); testWidgets('AutovalidateMode.always mode shows error from the start', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index c71b62fde7..ddc195adfa 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -1519,7 +1519,7 @@ void main() { testWidgets('BottomNavigationBar change backgroundColor test', (WidgetTester tester) async { // Regression test for: https://github.com/flutter/flutter/issues/19653 - Color _backgroundColor = Colors.red; + Color backgroundColor = Colors.red; await tester.pumpWidget( MaterialApp( @@ -1531,7 +1531,7 @@ void main() { child: const Text('green'), onPressed: () { setState(() { - _backgroundColor = Colors.green; + backgroundColor = Colors.green; }); }, ), @@ -1541,12 +1541,12 @@ void main() { items: [ BottomNavigationBarItem( label: 'Page 1', - backgroundColor: _backgroundColor, + backgroundColor: backgroundColor, icon: const Icon(Icons.dashboard), ), BottomNavigationBarItem( label: 'Page 2', - backgroundColor: _backgroundColor, + backgroundColor: backgroundColor, icon: const Icon(Icons.menu), ), ], @@ -1566,18 +1566,18 @@ void main() { }), ); - expect(_backgroundColor, Colors.red); + expect(backgroundColor, Colors.red); expect(tester.widget(backgroundMaterial).color, Colors.red); await tester.tap(find.text('green')); await tester.pumpAndSettle(); - expect(_backgroundColor, Colors.green); + expect(backgroundColor, Colors.green); expect(tester.widget(backgroundMaterial).color, Colors.green); }); group('BottomNavigationBar shifting backgroundColor with transition', () { // Regression test for: https://github.com/flutter/flutter/issues/22226 Widget runTest() { - int _currentIndex = 0; + int currentIndex = 0; return MaterialApp( home: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { @@ -1585,10 +1585,10 @@ void main() { bottomNavigationBar: RepaintBoundary( child: BottomNavigationBar( type: BottomNavigationBarType.shifting, - currentIndex: _currentIndex, + currentIndex: currentIndex, onTap: (int index) { setState(() { - _currentIndex = index; + currentIndex = index; }); }, items: const [ diff --git a/packages/flutter/test/material/checkbox_list_tile_test.dart b/packages/flutter/test/material/checkbox_list_tile_test.dart index 89052d5f48..4f7ea9e730 100644 --- a/packages/flutter/test/material/checkbox_list_tile_test.dart +++ b/packages/flutter/test/material/checkbox_list_tile_test.dart @@ -153,8 +153,8 @@ void main() { }); testWidgets('CheckboxListTile tristate test', (WidgetTester tester) async { - bool? _value = false; - bool _tristate = false; + bool? value = false; + bool tristate = false; await tester.pumpWidget( Material( @@ -163,11 +163,11 @@ void main() { return wrap( child: CheckboxListTile( title: const Text('Title'), - tristate: _tristate, - value: _value, - onChanged: (bool? value) { + tristate: tristate, + value: value, + onChanged: (bool? v) { setState(() { - _value = value; + value = v; }); }, ), @@ -182,23 +182,23 @@ void main() { // Tap the checkbox when tristate is disabled. await tester.tap(find.byType(Checkbox)); await tester.pumpAndSettle(); - expect(_value, true); + expect(value, true); await tester.tap(find.byType(Checkbox)); await tester.pumpAndSettle(); - expect(_value, false); + expect(value, false); // Tap the listTile when tristate is disabled. await tester.tap(find.byType(ListTile)); await tester.pumpAndSettle(); - expect(_value, true); + expect(value, true); await tester.tap(find.byType(ListTile)); await tester.pumpAndSettle(); - expect(_value, false); + expect(value, false); // Enable tristate - _tristate = true; + tristate = true; await tester.pumpAndSettle(); expect(tester.widget(find.byType(Checkbox)).value, false); @@ -206,28 +206,28 @@ void main() { // Tap the checkbox when tristate is enabled. await tester.tap(find.byType(Checkbox)); await tester.pumpAndSettle(); - expect(_value, true); + expect(value, true); await tester.tap(find.byType(Checkbox)); await tester.pumpAndSettle(); - expect(_value, null); + expect(value, null); await tester.tap(find.byType(Checkbox)); await tester.pumpAndSettle(); - expect(_value, false); + expect(value, false); // Tap the listTile when tristate is enabled. await tester.tap(find.byType(ListTile)); await tester.pumpAndSettle(); - expect(_value, true); + expect(value, true); await tester.tap(find.byType(ListTile)); await tester.pumpAndSettle(); - expect(_value, null); + expect(value, null); await tester.tap(find.byType(ListTile)); await tester.pumpAndSettle(); - expect(_value, false); + expect(value, false); }); testWidgets('CheckboxListTile respects shape', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/checkbox_test.dart b/packages/flutter/test/material/checkbox_test.dart index 2845fab585..733bc224c1 100644 --- a/packages/flutter/test/material/checkbox_test.dart +++ b/packages/flutter/test/material/checkbox_test.dart @@ -1081,7 +1081,7 @@ void main() { } const double splashRadius = 24.0; TestGesture gesture; - bool? _value = false; + bool? value = false; Widget buildTristateCheckbox() { return MaterialApp( @@ -1089,11 +1089,11 @@ void main() { body: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return Checkbox( - value: _value, + value: value, tristate: true, - onChanged: (bool? value) { + onChanged: (bool? v) { setState(() { - _value = value; + value = v; }); }, overlayColor: MaterialStateProperty.resolveWith(getOverlayColor), @@ -1110,7 +1110,7 @@ void main() { gesture = await tester.press(find.byType(Checkbox)); await tester.pumpAndSettle(); - expect(_value, false); + expect(value, false); expect( Material.of(tester.element(find.byType(Checkbox))), paints @@ -1126,7 +1126,7 @@ void main() { gesture = await tester.press(find.byType(Checkbox)); await tester.pumpAndSettle(); - expect(_value, true); + expect(value, true); expect( Material.of(tester.element(find.byType(Checkbox))), paints @@ -1142,7 +1142,7 @@ void main() { gesture = await tester.press(find.byType(Checkbox)); await tester.pumpAndSettle(); - expect(_value, null); + expect(value, null); expect( Material.of(tester.element(find.byType(Checkbox))), paints @@ -1158,7 +1158,7 @@ void main() { gesture = await tester.press(find.byType(Checkbox)); await tester.pumpAndSettle(); - expect(_value, false); + expect(value, false); expect( Material.of(tester.element(find.byType(Checkbox))), paints diff --git a/packages/flutter/test/material/data_table_test.dart b/packages/flutter/test/material/data_table_test.dart index 1381a68cad..f1eb9defc9 100644 --- a/packages/flutter/test/material/data_table_test.dart +++ b/packages/flutter/test/material/data_table_test.dart @@ -725,10 +725,10 @@ void main() { }); testWidgets('DataTable custom horizontal padding - checkbox', (WidgetTester tester) async { - const double _defaultHorizontalMargin = 24.0; - const double _defaultColumnSpacing = 56.0; - const double _customHorizontalMargin = 10.0; - const double _customColumnSpacing = 15.0; + const double defaultHorizontalMargin = 24.0; + const double defaultColumnSpacing = 56.0; + const double customHorizontalMargin = 10.0; + const double customColumnSpacing = 15.0; Finder cellContent; Finder checkbox; Finder padding; @@ -793,11 +793,11 @@ void main() { padding = find.ancestor(of: checkbox, matching: find.byType(Padding)); expect( tester.getRect(checkbox).left - tester.getRect(padding).left, - _defaultHorizontalMargin, + defaultHorizontalMargin, ); expect( tester.getRect(padding).right - tester.getRect(checkbox).right, - _defaultHorizontalMargin / 2, + defaultHorizontalMargin / 2, ); // default first column padding @@ -805,11 +805,11 @@ void main() { cellContent = find.widgetWithText(Align, 'Frozen yogurt'); // DataTable wraps its DataCells in an Align widget expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _defaultHorizontalMargin / 2, + defaultHorizontalMargin / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); // default middle column padding @@ -817,11 +817,11 @@ void main() { cellContent = find.widgetWithText(Align, '159'); expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); // default last column padding @@ -829,11 +829,11 @@ void main() { cellContent = find.widgetWithText(Align, '6.0'); expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _defaultHorizontalMargin, + defaultHorizontalMargin, ); Widget buildCustomTable({ @@ -893,8 +893,8 @@ void main() { // CUSTOM VALUES await tester.pumpWidget(MaterialApp( home: Material(child: buildCustomTable( - horizontalMargin: _customHorizontalMargin, - columnSpacing: _customColumnSpacing, + horizontalMargin: customHorizontalMargin, + columnSpacing: customColumnSpacing, )), )); @@ -903,11 +903,11 @@ void main() { padding = find.ancestor(of: checkbox, matching: find.byType(Padding)); expect( tester.getRect(checkbox).left - tester.getRect(padding).left, - _customHorizontalMargin, + customHorizontalMargin, ); expect( tester.getRect(padding).right - tester.getRect(checkbox).right, - _customHorizontalMargin / 2, + customHorizontalMargin / 2, ); // custom first column padding @@ -915,11 +915,11 @@ void main() { cellContent = find.widgetWithText(Align, 'Frozen yogurt'); // DataTable wraps its DataCells in an Align widget expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _customHorizontalMargin / 2, + customHorizontalMargin / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); // custom middle column padding @@ -927,11 +927,11 @@ void main() { cellContent = find.widgetWithText(Align, '159'); expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); // custom last column padding @@ -939,19 +939,19 @@ void main() { cellContent = find.widgetWithText(Align, '6.0'); expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _customHorizontalMargin, + customHorizontalMargin, ); }); testWidgets('DataTable custom horizontal padding - no checkbox', (WidgetTester tester) async { - const double _defaultHorizontalMargin = 24.0; - const double _defaultColumnSpacing = 56.0; - const double _customHorizontalMargin = 10.0; - const double _customColumnSpacing = 15.0; + const double defaultHorizontalMargin = 24.0; + const double defaultColumnSpacing = 56.0; + const double customHorizontalMargin = 10.0; + const double customColumnSpacing = 15.0; Finder cellContent; Finder padding; @@ -1013,11 +1013,11 @@ void main() { cellContent = find.widgetWithText(Align, 'Frozen yogurt'); // DataTable wraps its DataCells in an Align widget expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _defaultHorizontalMargin, + defaultHorizontalMargin, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); // default middle column padding @@ -1025,11 +1025,11 @@ void main() { cellContent = find.widgetWithText(Align, '159'); expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); // default last column padding @@ -1037,11 +1037,11 @@ void main() { cellContent = find.widgetWithText(Align, '6.0'); expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _defaultHorizontalMargin, + defaultHorizontalMargin, ); Widget buildCustomTable({ @@ -1099,8 +1099,8 @@ void main() { // CUSTOM VALUES await tester.pumpWidget(MaterialApp( home: Material(child: buildCustomTable( - horizontalMargin: _customHorizontalMargin, - columnSpacing: _customColumnSpacing, + horizontalMargin: customHorizontalMargin, + columnSpacing: customColumnSpacing, )), )); @@ -1109,11 +1109,11 @@ void main() { cellContent = find.widgetWithText(Align, 'Frozen yogurt'); // DataTable wraps its DataCells in an Align widget expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _customHorizontalMargin, + customHorizontalMargin, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); // custom middle column padding @@ -1121,11 +1121,11 @@ void main() { cellContent = find.widgetWithText(Align, '159'); expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); // custom last column padding @@ -1133,11 +1133,11 @@ void main() { cellContent = find.widgetWithText(Align, '6.0'); expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _customHorizontalMargin, + customHorizontalMargin, ); }); @@ -1356,10 +1356,10 @@ void main() { }); testWidgets('DataRow renders default selected row colors', (WidgetTester tester) async { - final ThemeData _themeData = ThemeData.light(); + final ThemeData themeData = ThemeData.light(); Widget buildTable({bool selected = false}) { return MaterialApp( - theme: _themeData, + theme: themeData, home: Material( child: DataTable( columns: const [ @@ -1393,7 +1393,7 @@ void main() { await tester.pumpWidget(buildTable(selected: true)); expect( lastTableRowBoxDecoration().color, - _themeData.colorScheme.primary.withOpacity(0.08), + themeData.colorScheme.primary.withOpacity(0.08), ); }); @@ -1401,7 +1401,7 @@ void main() { const Color fillColor = Color(0xFF00FF00); const Color checkColor = Color(0xFF0000FF); - final ThemeData _themeData = ThemeData( + final ThemeData themeData = ThemeData( checkboxTheme: CheckboxThemeData( fillColor: MaterialStateProperty.all(fillColor), checkColor: MaterialStateProperty.all(checkColor), @@ -1409,7 +1409,7 @@ void main() { ); Widget buildTable() { return MaterialApp( - theme: _themeData, + theme: themeData, home: Material( child: DataTable( columns: const [ @@ -1658,8 +1658,8 @@ void main() { }); testWidgets('checkboxHorizontalMargin properly applied', (WidgetTester tester) async { - const double _customCheckboxHorizontalMargin = 15.0; - const double _customHorizontalMargin = 10.0; + const double customCheckboxHorizontalMargin = 15.0; + const double customHorizontalMargin = 10.0; Finder cellContent; Finder checkbox; Finder padding; @@ -1720,8 +1720,8 @@ void main() { await tester.pumpWidget(MaterialApp( home: Material(child: buildCustomTable( - checkboxHorizontalMargin: _customCheckboxHorizontalMargin, - horizontalMargin: _customHorizontalMargin, + checkboxHorizontalMargin: customCheckboxHorizontalMargin, + horizontalMargin: customHorizontalMargin, )), )); @@ -1730,11 +1730,11 @@ void main() { padding = find.ancestor(of: checkbox, matching: find.byType(Padding)); expect( tester.getRect(checkbox).left - tester.getRect(padding).left, - _customCheckboxHorizontalMargin, + customCheckboxHorizontalMargin, ); expect( tester.getRect(padding).right - tester.getRect(checkbox).right, - _customCheckboxHorizontalMargin, + customCheckboxHorizontalMargin, ); // First column padding. @@ -1742,7 +1742,7 @@ void main() { cellContent = find.widgetWithText(Align, 'Frozen yogurt'); // DataTable wraps its DataCells in an Align widget. expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _customHorizontalMargin, + customHorizontalMargin, ); }); diff --git a/packages/flutter/test/material/debug_test.dart b/packages/flutter/test/material/debug_test.dart index e319132463..c0155f9f90 100644 --- a/packages/flutter/test/material/debug_test.dart +++ b/packages/flutter/test/material/debug_test.dart @@ -220,8 +220,8 @@ void main() { }); testWidgets('debugCheckHasScaffoldMessenger control test', (WidgetTester tester) async { - final GlobalKey _scaffoldKey = GlobalKey(); - final GlobalKey _scaffoldMessengerKey = GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); + final GlobalKey scaffoldMessengerKey = GlobalKey(); final SnackBar snackBar = SnackBar( content: const Text('Snack'), action: SnackBarAction(label: 'Test', onPressed: () {}), @@ -231,11 +231,11 @@ void main() { child: MediaQuery( data: const MediaQueryData(), child: ScaffoldMessenger( - key: _scaffoldMessengerKey, + key: scaffoldMessengerKey, child: Builder( builder: (BuildContext context) { return Scaffold( - key: _scaffoldKey, + key: scaffoldKey, body: Container(), ); }, @@ -249,7 +249,7 @@ void main() { exceptions.add(details.exception); }; // ScaffoldMessenger shows SnackBar. - _scaffoldMessengerKey.currentState!.showSnackBar(snackBar); + scaffoldMessengerKey.currentState!.showSnackBar(snackBar); await tester.pumpAndSettle(); // Pump widget to rebuild without ScaffoldMessenger @@ -258,7 +258,7 @@ void main() { child: MediaQuery( data: const MediaQueryData(), child: Scaffold( - key: _scaffoldKey, + key: scaffoldKey, body: Container(), ), ), diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart index 1d3f6e8aae..a6f4763547 100644 --- a/packages/flutter/test/material/dialog_test.dart +++ b/packages/flutter/test/material/dialog_test.dart @@ -1551,13 +1551,13 @@ void main() { }); testWidgets('Dismissible.confirmDismiss defers to an AlertDialog', (WidgetTester tester) async { - final GlobalKey _scaffoldKey = GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); final List dismissedItems = []; // Dismiss is confirmed IFF confirmDismiss() returns true. Future confirmDismiss (DismissDirection dismissDirection) async { return showDialog( - context: _scaffoldKey.currentContext!, + context: scaffoldKey.currentContext!, barrierDismissible: true, // showDialog() returns null if tapped outside the dialog builder: (BuildContext context) { return AlertDialog( @@ -1602,7 +1602,7 @@ void main() { home: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return Scaffold( - key: _scaffoldKey, + key: scaffoldKey, body: Padding( padding: const EdgeInsets.all(16.0), child: ListView( diff --git a/packages/flutter/test/material/dropdown_form_field_test.dart b/packages/flutter/test/material/dropdown_form_field_test.dart index 5424c20b08..a8f8bd082b 100644 --- a/packages/flutter/test/material/dropdown_form_field_test.dart +++ b/packages/flutter/test/material/dropdown_form_field_test.dart @@ -446,7 +446,7 @@ void main() { testWidgets('DropdownButtonFormField with autovalidation test', (WidgetTester tester) async { String? value = 'one'; - int _validateCalled = 0; + int validateCalled = 0; await tester.pumpWidget( StatefulBuilder( @@ -471,7 +471,7 @@ void main() { }); }, validator: (String? currentValue) { - _validateCalled++; + validateCalled++; return currentValue == null ? 'Must select value' : null; }, autovalidateMode: AutovalidateMode.always, @@ -482,13 +482,13 @@ void main() { ), ); - expect(_validateCalled, 1); + expect(validateCalled, 1); expect(value, equals('one')); await tester.tap(find.text('one')); await tester.pumpAndSettle(); await tester.tap(find.text('three').last); await tester.pump(); - expect(_validateCalled, 2); + expect(validateCalled, 2); await tester.pumpAndSettle(); expect(value, equals('three')); }); @@ -1050,7 +1050,7 @@ void main() { }); testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async { - int _validateCalled = 0; + int validateCalled = 0; await tester.pumpWidget( MaterialApp( @@ -1066,7 +1066,7 @@ void main() { }).toList(), onChanged: onChanged, validator: (String? value) { - _validateCalled++; + validateCalled++; return null; }, ), @@ -1075,7 +1075,7 @@ void main() { ), ); - expect(_validateCalled, 1); + expect(validateCalled, 1); }); testWidgets('DropdownButtonFormField - Custom button alignment', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/expansion_panel_test.dart b/packages/flutter/test/material/expansion_panel_test.dart index beae622220..1a63ffb356 100644 --- a/packages/flutter/test/material/expansion_panel_test.dart +++ b/packages/flutter/test/material/expansion_panel_test.dart @@ -42,9 +42,9 @@ class _SimpleExpansionPanelListTestWidgetState extends State[ ExpansionPanel( @@ -143,8 +143,8 @@ void main() { final double oldHeight = box.size.height; expect(find.byType(ExpandIcon), findsOneWidget); await tester.tap(find.byType(ExpandIcon)); - expect(index, 0); - expect(isExpanded, isFalse); + expect(capturedIndex, 0); + expect(capturedIsExpanded, isFalse); box = tester.renderObject(find.byType(ExpansionPanelList)); expect(box.size.height, equals(oldHeight)); @@ -153,9 +153,9 @@ void main() { MaterialApp( home: SingleChildScrollView( child: ExpansionPanelList( - expansionCallback: (int _index, bool _isExpanded) { - index = _index; - isExpanded = _isExpanded; + expansionCallback: (int index, bool isExpanded) { + capturedIndex = index; + capturedIsExpanded = isExpanded; }, children: [ ExpansionPanel( @@ -359,7 +359,7 @@ void main() { }); testWidgets('Radio mode has max of one panel open at a time', (WidgetTester tester) async { - final List _demoItemsRadio = [ + final List demoItemsRadio = [ ExpansionPanelRadio( headerBuilder: (BuildContext context, bool isExpanded) { return Text(isExpanded ? 'B' : 'A'); @@ -383,14 +383,14 @@ void main() { ), ]; - final ExpansionPanelList _expansionListRadio = ExpansionPanelList.radio( - children: _demoItemsRadio, + final ExpansionPanelList expansionListRadio = ExpansionPanelList.radio( + children: demoItemsRadio, ); await tester.pumpWidget( MaterialApp( home: SingleChildScrollView( - child: _expansionListRadio, + child: expansionListRadio, ), ), ); @@ -444,7 +444,7 @@ void main() { expect(box.size.height, greaterThanOrEqualTo(oldHeight)); - _demoItemsRadio.removeAt(0); + demoItemsRadio.removeAt(0); await tester.pumpAndSettle(); @@ -455,7 +455,7 @@ void main() { expect(find.text('F'), findsNothing); - final List _demoItems = [ + final List demoItems = [ ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) { return Text(isExpanded ? 'B' : 'A'); @@ -476,14 +476,14 @@ void main() { ), ]; - final ExpansionPanelList _expansionList = ExpansionPanelList( - children: _demoItems, + final ExpansionPanelList expansionList = ExpansionPanelList( + children: demoItems, ); await tester.pumpWidget( MaterialApp( home: SingleChildScrollView( - child: _expansionList, + child: expansionList, ), ), ); @@ -498,7 +498,7 @@ void main() { }); testWidgets('Radio mode calls expansionCallback once if other panels closed', (WidgetTester tester) async { - final List _demoItemsRadio = [ + final List demoItemsRadio = [ ExpansionPanelRadio( headerBuilder: (BuildContext context, bool isExpanded) { return Text(isExpanded ? 'B' : 'A'); @@ -523,20 +523,20 @@ void main() { ]; final List> callbackHistory = >[]; - final ExpansionPanelList _expansionListRadio = ExpansionPanelList.radio( - expansionCallback: (int _index, bool _isExpanded) { + final ExpansionPanelList expansionListRadio = ExpansionPanelList.radio( + expansionCallback: (int index, bool isExpanded) { callbackHistory.add({ - 'index': _index, - 'isExpanded': _isExpanded, + 'index': index, + 'isExpanded': isExpanded, }); }, - children: _demoItemsRadio, + children: demoItemsRadio, ); await tester.pumpWidget( MaterialApp( home: SingleChildScrollView( - child: _expansionListRadio, + child: expansionListRadio, ), ), ); @@ -569,7 +569,7 @@ void main() { }); testWidgets('Radio mode calls expansionCallback twice if other panel open prior', (WidgetTester tester) async { - final List _demoItemsRadio = [ + final List demoItemsRadio = [ ExpansionPanelRadio( headerBuilder: (BuildContext context, bool isExpanded) { return Text(isExpanded ? 'B' : 'A'); @@ -596,20 +596,20 @@ void main() { final List> callbackHistory = >[]; Map callbackResults; - final ExpansionPanelList _expansionListRadio = ExpansionPanelList.radio( - expansionCallback: (int _index, bool _isExpanded) { + final ExpansionPanelList expansionListRadio = ExpansionPanelList.radio( + expansionCallback: (int index, bool isExpanded) { callbackHistory.add({ - 'index': _index, - 'isExpanded': _isExpanded, + 'index': index, + 'isExpanded': isExpanded, }); }, - children: _demoItemsRadio, + children: demoItemsRadio, ); await tester.pumpWidget( MaterialApp( home: SingleChildScrollView( - child: _expansionListRadio, + child: expansionListRadio, ), ), ); @@ -653,7 +653,7 @@ void main() { 'and ExpansionPaneList.radio', (WidgetTester tester) async { bool isRadioList = false; - final List _panelExpansionState = [ + final List panelExpansionState = [ false, false, false, @@ -690,24 +690,24 @@ void main() { ExpansionPanelList buildExpansionPanelList(StateSetter setState) { return ExpansionPanelList( - expansionCallback: (int index, _) => setState(() { _panelExpansionState[index] = !_panelExpansionState[index]; }), + expansionCallback: (int index, _) => setState(() { panelExpansionState[index] = !panelExpansionState[index]; }), children: [ ExpansionPanel( - isExpanded: _panelExpansionState[0], + isExpanded: panelExpansionState[0], headerBuilder: (BuildContext context, bool isExpanded) { return Text(isExpanded ? 'B' : 'A'); }, body: const SizedBox(height: 100.0), ), ExpansionPanel( - isExpanded: _panelExpansionState[1], + isExpanded: panelExpansionState[1], headerBuilder: (BuildContext context, bool isExpanded) { return Text(isExpanded ? 'D' : 'C'); }, body: const SizedBox(height: 100.0), ), ExpansionPanel( - isExpanded: _panelExpansionState[2], + isExpanded: panelExpansionState[2], headerBuilder: (BuildContext context, bool isExpanded) { return Text(isExpanded ? 'F' : 'E'); }, @@ -907,7 +907,7 @@ void main() { const Key collapsedKey = Key('collapsed'); const DefaultMaterialLocalizations localizations = DefaultMaterialLocalizations(); final SemanticsHandle handle = tester.ensureSemantics(); - final List _demoItems = [ + final List demoItems = [ ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) { return const Text('Expanded', key: expandedKey); @@ -923,14 +923,14 @@ void main() { ), ]; - final ExpansionPanelList _expansionList = ExpansionPanelList( - children: _demoItems, + final ExpansionPanelList expansionList = ExpansionPanelList( + children: demoItems, ); await tester.pumpWidget( MaterialApp( home: SingleChildScrollView( - child: _expansionList, + child: expansionList, ), ), ); @@ -990,7 +990,7 @@ void main() { const Key expandedKey = Key('expanded'); const Key collapsedKey = Key('collapsed'); final SemanticsHandle handle = tester.ensureSemantics(); - final List _demoItems = [ + final List demoItems = [ ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) { return const Text('Expanded', key: expandedKey); @@ -1008,14 +1008,14 @@ void main() { ), ]; - final ExpansionPanelList _expansionList = ExpansionPanelList( - children: _demoItems, + final ExpansionPanelList expansionList = ExpansionPanelList( + children: demoItems, ); await tester.pumpWidget( MaterialApp( home: SingleChildScrollView( - child: _expansionList, + child: expansionList, ), ), ); @@ -1040,19 +1040,19 @@ void main() { }); testWidgets('Ensure canTapOnHeader is false by default', (WidgetTester tester) async { - final ExpansionPanel _expansionPanel = ExpansionPanel( + final ExpansionPanel expansionPanel = ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) => const Text('Demo'), body: const SizedBox(height: 100.0), ); - expect(_expansionPanel.canTapOnHeader, isFalse); + expect(expansionPanel.canTapOnHeader, isFalse); }); testWidgets('Toggle ExpansionPanelRadio when tapping header and canTapOnHeader is true', (WidgetTester tester) async { const Key firstPanelKey = Key('firstPanelKey'); const Key secondPanelKey = Key('secondPanelKey'); - final List _demoItemsRadio = [ + final List demoItemsRadio = [ ExpansionPanelRadio( headerBuilder: (BuildContext context, bool isExpanded) { return Text(isExpanded ? 'B' : 'A', key: firstPanelKey); @@ -1071,14 +1071,14 @@ void main() { ), ]; - final ExpansionPanelList _expansionListRadio = ExpansionPanelList.radio( - children: _demoItemsRadio, + final ExpansionPanelList expansionListRadio = ExpansionPanelList.radio( + children: demoItemsRadio, ); await tester.pumpWidget( MaterialApp( home: SingleChildScrollView( - child: _expansionListRadio, + child: expansionListRadio, ), ), ); @@ -1211,7 +1211,7 @@ void main() { const Key firstPanelKey = Key('firstPanelKey'); const Key secondPanelKey = Key('secondPanelKey'); - final List _demoItemsRadio = [ + final List demoItemsRadio = [ ExpansionPanelRadio( headerBuilder: (BuildContext context, bool isExpanded) { return Text(isExpanded ? 'B' : 'A', key: firstPanelKey); @@ -1228,14 +1228,14 @@ void main() { ), ]; - final ExpansionPanelList _expansionListRadio = ExpansionPanelList.radio( - children: _demoItemsRadio, + final ExpansionPanelList expansionListRadio = ExpansionPanelList.radio( + children: demoItemsRadio, ); await tester.pumpWidget( MaterialApp( home: SingleChildScrollView( - child: _expansionListRadio, + child: expansionListRadio, ), ), ); @@ -1391,24 +1391,24 @@ void main() { }); testWidgets('elevation is propagated properly to MergeableMaterial', (WidgetTester tester) async { - const double _elevation = 8; + const double elevation = 8; // Test for ExpansionPanelList. await tester.pumpWidget(const MaterialApp( home: SingleChildScrollView( child: SimpleExpansionPanelListTestWidget( - elevation: _elevation, + elevation: elevation, ), ), )); - expect(tester.widget(find.byType(MergeableMaterial)).elevation, _elevation); + expect(tester.widget(find.byType(MergeableMaterial)).elevation, elevation); // Test for ExpansionPanelList.radio. await tester.pumpWidget(MaterialApp( home: SingleChildScrollView( child: ExpansionPanelList.radio( - elevation: _elevation, + elevation: elevation, children: [ ExpansionPanelRadio( headerBuilder: (BuildContext context, bool isExpanded) { @@ -1429,7 +1429,7 @@ void main() { ), )); - expect(tester.widget(find.byType(MergeableMaterial)).elevation, _elevation); + expect(tester.widget(find.byType(MergeableMaterial)).elevation, elevation); }); testWidgets('Using a value non defined value throws assertion error', (WidgetTester tester) async { @@ -1459,7 +1459,7 @@ void main() { MaterialApp( home: SingleChildScrollView( child: ExpansionPanelList( - expansionCallback: (int _index, bool _isExpanded) {}, + expansionCallback: (int index, bool isExpanded) {}, children: [ ExpansionPanel( backgroundColor: firstPanelColor, diff --git a/packages/flutter/test/material/expansion_tile_test.dart b/packages/flutter/test/material/expansion_tile_test.dart index a6ae70eb3e..85ba3e4352 100644 --- a/packages/flutter/test/material/expansion_tile_test.dart +++ b/packages/flutter/test/material/expansion_tile_test.dart @@ -42,10 +42,10 @@ class TestTextState extends State { } void main() { - const Color _dividerColor = Color(0x1f333333); - const Color _foregroundColor = Colors.blueAccent; - const Color _unselectedWidgetColor = Colors.black54; - const Color _headerColor = Colors.black45; + const Color dividerColor = Color(0x1f333333); + const Color foregroundColor = Colors.blueAccent; + const Color unselectedWidgetColor = Colors.black54; + const Color headerColor = Colors.black45; testWidgets('ExpansionTile initial state', (WidgetTester tester) async { final Key topKey = UniqueKey(); @@ -57,7 +57,7 @@ void main() { await tester.pumpWidget(MaterialApp( theme: ThemeData( - dividerColor: _dividerColor, + dividerColor: dividerColor, ), home: Material( child: SingleChildScrollView( @@ -111,8 +111,8 @@ void main() { BoxDecoration expandedContainerDecoration = getContainer(expandedKey).decoration! as BoxDecoration; expect(expandedContainerDecoration.color, Colors.red); - expect(expandedContainerDecoration.border!.top.color, _dividerColor); - expect(expandedContainerDecoration.border!.bottom.color, _dividerColor); + expect(expandedContainerDecoration.border!.top.color, dividerColor); + expect(expandedContainerDecoration.border!.bottom.color, dividerColor); BoxDecoration collapsedContainerDecoration = getContainer(collapsedKey).decoration! as BoxDecoration; expect(collapsedContainerDecoration.color, Colors.transparent); @@ -149,8 +149,8 @@ void main() { // Collapsed should be expanded now. collapsedContainerDecoration = getContainer(collapsedKey).decoration! as BoxDecoration; expect(collapsedContainerDecoration.color, Colors.transparent); - expect(collapsedContainerDecoration.border!.top.color, _dividerColor); - expect(collapsedContainerDecoration.border!.bottom.color, _dividerColor); + expect(collapsedContainerDecoration.border!.top.color, dividerColor); + expect(collapsedContainerDecoration.border!.bottom.color, dividerColor); }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); testWidgets('ExpansionTile Theme dependencies', (WidgetTester tester) async { @@ -162,9 +162,9 @@ void main() { await tester.pumpWidget( MaterialApp( theme: ThemeData( - colorScheme: ColorScheme.fromSwatch().copyWith(primary: _foregroundColor), - unselectedWidgetColor: _unselectedWidgetColor, - textTheme: const TextTheme(subtitle1: TextStyle(color: _headerColor)), + colorScheme: ColorScheme.fromSwatch().copyWith(primary: foregroundColor), + unselectedWidgetColor: unselectedWidgetColor, + textTheme: const TextTheme(subtitle1: TextStyle(color: headerColor)), ), home: Material( child: SingleChildScrollView( @@ -193,10 +193,10 @@ void main() { Color iconColor(Key key) => tester.state(find.byKey(key)).iconTheme.color!; Color textColor(Key key) => tester.state(find.byKey(key)).textStyle.color!; - expect(textColor(expandedTitleKey), _foregroundColor); - expect(textColor(collapsedTitleKey), _headerColor); - expect(iconColor(expandedIconKey), _foregroundColor); - expect(iconColor(collapsedIconKey), _unselectedWidgetColor); + expect(textColor(expandedTitleKey), foregroundColor); + expect(textColor(collapsedTitleKey), headerColor); + expect(iconColor(expandedIconKey), foregroundColor); + expect(iconColor(collapsedIconKey), unselectedWidgetColor); // Tap both tiles to change their state: collapse and extend respectively await tester.tap(find.text('Expanded')); @@ -205,10 +205,10 @@ void main() { await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1)); - expect(textColor(expandedTitleKey), _headerColor); - expect(textColor(collapsedTitleKey), _foregroundColor); - expect(iconColor(expandedIconKey), _unselectedWidgetColor); - expect(iconColor(collapsedIconKey), _foregroundColor); + expect(textColor(expandedTitleKey), headerColor); + expect(textColor(collapsedTitleKey), foregroundColor); + expect(iconColor(expandedIconKey), unselectedWidgetColor); + expect(iconColor(collapsedIconKey), foregroundColor); }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); testWidgets('ExpansionTile subtitle', (WidgetTester tester) async { @@ -232,7 +232,7 @@ void main() { MaterialApp( theme: ThemeData( platform: TargetPlatform.iOS, - dividerColor: _dividerColor, + dividerColor: dividerColor, ), home: Material( child: SingleChildScrollView( diff --git a/packages/flutter/test/material/navigation_bar_test.dart b/packages/flutter/test/material/navigation_bar_test.dart index ee29b6f47f..615b14d8c2 100644 --- a/packages/flutter/test/material/navigation_bar_test.dart +++ b/packages/flutter/test/material/navigation_bar_test.dart @@ -341,14 +341,14 @@ void main() { }); testWidgets('Navigation bar does not grow with text scale factor', (WidgetTester tester) async { - const int _animationMilliseconds = 800; + const int animationMilliseconds = 800; Widget _widget({double textScaleFactor = 1}) { return _buildWidget( MediaQuery( data: MediaQueryData(textScaleFactor: textScaleFactor), child: NavigationBar( - animationDuration: const Duration(milliseconds: _animationMilliseconds), + animationDuration: const Duration(milliseconds: animationMilliseconds), destinations: const [ NavigationDestination( icon: Icon(Icons.ac_unit), diff --git a/packages/flutter/test/material/paginated_data_table_test.dart b/packages/flutter/test/material/paginated_data_table_test.dart index 53649cf7a6..90ff01e472 100644 --- a/packages/flutter/test/material/paginated_data_table_test.dart +++ b/packages/flutter/test/material/paginated_data_table_test.dart @@ -481,19 +481,19 @@ void main() { }); testWidgets('PaginatedDataTable custom horizontal padding - checkbox', (WidgetTester tester) async { - const double _defaultHorizontalMargin = 24.0; - const double _defaultColumnSpacing = 56.0; - const double _customHorizontalMargin = 10.0; - const double _customColumnSpacing = 15.0; + const double defaultHorizontalMargin = 24.0; + const double defaultColumnSpacing = 56.0; + const double customHorizontalMargin = 10.0; + const double customColumnSpacing = 15.0; - const double _width = 400; - const double _height = 400; + const double width = 400; + const double height = 400; final Size originalSize = binding.renderView.size; // Ensure the containing Card is small enough that we don't expand too // much, resulting in our custom margin being ignored. - await binding.setSurfaceSize(const Size(_width, _height)); + await binding.setSurfaceSize(const Size(width, height)); final TestDataSource source = TestDataSource(allowSelection: true); Finder cellContent; @@ -524,11 +524,11 @@ void main() { padding = find.ancestor(of: checkbox, matching: find.byType(Padding)).first; expect( tester.getRect(checkbox).left - tester.getRect(padding).left, - _defaultHorizontalMargin, + defaultHorizontalMargin, ); expect( tester.getRect(padding).right - tester.getRect(checkbox).right, - _defaultHorizontalMargin / 2, + defaultHorizontalMargin / 2, ); // default first column padding @@ -536,11 +536,11 @@ void main() { cellContent = find.widgetWithText(Align, 'Frozen yogurt (0)'); // DataTable wraps its DataCells in an Align widget expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _defaultHorizontalMargin / 2, + defaultHorizontalMargin / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); // default middle column padding @@ -548,11 +548,11 @@ void main() { cellContent = find.widgetWithText(Align, '159'); expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); // default last column padding @@ -560,11 +560,11 @@ void main() { cellContent = find.widgetWithText(Align, '0').first; expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _defaultHorizontalMargin, + defaultHorizontalMargin, ); // CUSTOM VALUES @@ -585,8 +585,8 @@ void main() { DataColumn(label: Text('Calories'), numeric: true), DataColumn(label: Text('Generation')), ], - horizontalMargin: _customHorizontalMargin, - columnSpacing: _customColumnSpacing, + horizontalMargin: customHorizontalMargin, + columnSpacing: customColumnSpacing, ), ), )); @@ -596,11 +596,11 @@ void main() { padding = find.ancestor(of: checkbox, matching: find.byType(Padding)).first; expect( tester.getRect(checkbox).left - tester.getRect(padding).left, - _customHorizontalMargin, + customHorizontalMargin, ); expect( tester.getRect(padding).right - tester.getRect(checkbox).right, - _customHorizontalMargin / 2, + customHorizontalMargin / 2, ); // custom first column padding @@ -608,11 +608,11 @@ void main() { cellContent = find.widgetWithText(Align, 'Frozen yogurt (0)'); // DataTable wraps its DataCells in an Align widget expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _customHorizontalMargin / 2, + customHorizontalMargin / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); // custom middle column padding @@ -620,11 +620,11 @@ void main() { cellContent = find.widgetWithText(Align, '159'); expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); // custom last column padding @@ -632,11 +632,11 @@ void main() { cellContent = find.widgetWithText(Align, '0').first; expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _customHorizontalMargin, + customHorizontalMargin, ); // Reset the surface size. @@ -644,10 +644,10 @@ void main() { }); testWidgets('PaginatedDataTable custom horizontal padding - no checkbox', (WidgetTester tester) async { - const double _defaultHorizontalMargin = 24.0; - const double _defaultColumnSpacing = 56.0; - const double _customHorizontalMargin = 10.0; - const double _customColumnSpacing = 15.0; + const double defaultHorizontalMargin = 24.0; + const double defaultColumnSpacing = 56.0; + const double customHorizontalMargin = 10.0; + const double customColumnSpacing = 15.0; final TestDataSource source = TestDataSource(); Finder cellContent; Finder padding; @@ -675,11 +675,11 @@ void main() { cellContent = find.widgetWithText(Align, 'Frozen yogurt (0)'); // DataTable wraps its DataCells in an Align widget expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _defaultHorizontalMargin, + defaultHorizontalMargin, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); // default middle column padding @@ -687,11 +687,11 @@ void main() { cellContent = find.widgetWithText(Align, '159'); expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); // default last column padding @@ -699,11 +699,11 @@ void main() { cellContent = find.widgetWithText(Align, '0').first; expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _defaultColumnSpacing / 2, + defaultColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _defaultHorizontalMargin, + defaultHorizontalMargin, ); // CUSTOM VALUES @@ -723,8 +723,8 @@ void main() { DataColumn(label: Text('Calories'), numeric: true), DataColumn(label: Text('Generation')), ], - horizontalMargin: _customHorizontalMargin, - columnSpacing: _customColumnSpacing, + horizontalMargin: customHorizontalMargin, + columnSpacing: customColumnSpacing, ), ), )); @@ -734,11 +734,11 @@ void main() { cellContent = find.widgetWithText(Align, 'Frozen yogurt (0)'); expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _customHorizontalMargin, + customHorizontalMargin, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); // custom middle column padding @@ -746,11 +746,11 @@ void main() { cellContent = find.widgetWithText(Align, '159'); expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); // custom last column padding @@ -758,11 +758,11 @@ void main() { cellContent = find.widgetWithText(Align, '0').first; expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _customColumnSpacing / 2, + customColumnSpacing / 2, ); expect( tester.getRect(padding).right - tester.getRect(cellContent).right, - _customHorizontalMargin, + customHorizontalMargin, ); }); @@ -772,14 +772,14 @@ void main() { // Note: 800 is wide enough to ensure that all of the columns fit in the // Card. The test makes sure that the DataTable is exactly as wide // as the Card, minus the Card's margin. - const double _originalWidth = 800; - const double _expandedWidth = 1600; - const double _height = 400; + const double originalWidth = 800; + const double expandedWidth = 1600; + const double height = 400; // By default, the margin of a Card is 4 in all directions, so // the size of the DataTable (inside the Card) is horizontically // reduced by 4 * 2; the left and right margins. - const double _cardMargin = 8; + const double cardMargin = 8; final Size originalSize = binding.renderView.size; @@ -801,7 +801,7 @@ void main() { ), ); - await binding.setSurfaceSize(const Size(_originalWidth, _height)); + await binding.setSurfaceSize(const Size(originalWidth, height)); await tester.pumpWidget(buildWidget()); double cardWidth = tester.renderObject(find.byType(Card).first).size.width; @@ -809,10 +809,10 @@ void main() { // Widths should be equal before we resize... expect( tester.renderObject(find.byType(DataTable).first).size.width, - moreOrLessEquals(cardWidth - _cardMargin), + moreOrLessEquals(cardWidth - cardMargin), ); - await binding.setSurfaceSize(const Size(_expandedWidth, _height)); + await binding.setSurfaceSize(const Size(expandedWidth, height)); await tester.pumpWidget(buildWidget()); cardWidth = tester.renderObject(find.byType(Card).first).size.width; @@ -820,11 +820,11 @@ void main() { // ... and should still be equal after the resize. expect( tester.renderObject(find.byType(DataTable).first).size.width, - moreOrLessEquals(cardWidth - _cardMargin), + moreOrLessEquals(cardWidth - cardMargin), ); // Double check to ensure we actually resized the surface properly. - expect(cardWidth, moreOrLessEquals(_expandedWidth)); + expect(cardWidth, moreOrLessEquals(expandedWidth)); // Reset the surface size. await binding.setSurfaceSize(originalSize); @@ -885,17 +885,17 @@ void main() { }); testWidgets('PaginatedDataTable custom checkboxHorizontalMargin properly applied', (WidgetTester tester) async { - const double _customCheckboxHorizontalMargin = 15.0; - const double _customHorizontalMargin = 10.0; + const double customCheckboxHorizontalMargin = 15.0; + const double customHorizontalMargin = 10.0; - const double _width = 400; - const double _height = 400; + const double width = 400; + const double height = 400; final Size originalSize = binding.renderView.size; // Ensure the containing Card is small enough that we don't expand too // much, resulting in our custom margin being ignored. - await binding.setSurfaceSize(const Size(_width, _height)); + await binding.setSurfaceSize(const Size(width, height)); final TestDataSource source = TestDataSource(allowSelection: true); Finder cellContent; @@ -920,8 +920,8 @@ void main() { DataColumn(label: Text('Calories'), numeric: true), DataColumn(label: Text('Generation')), ], - horizontalMargin: _customHorizontalMargin, - checkboxHorizontalMargin: _customCheckboxHorizontalMargin, + horizontalMargin: customHorizontalMargin, + checkboxHorizontalMargin: customCheckboxHorizontalMargin, ), ), )); @@ -931,11 +931,11 @@ void main() { padding = find.ancestor(of: checkbox, matching: find.byType(Padding)).first; expect( tester.getRect(checkbox).left - tester.getRect(padding).left, - _customCheckboxHorizontalMargin, + customCheckboxHorizontalMargin, ); expect( tester.getRect(padding).right - tester.getRect(checkbox).right, - _customCheckboxHorizontalMargin, + customCheckboxHorizontalMargin, ); // Custom first column padding. @@ -943,7 +943,7 @@ void main() { cellContent = find.widgetWithText(Align, 'Frozen yogurt (0)'); // DataTable wraps its DataCells in an Align widget. expect( tester.getRect(cellContent).left - tester.getRect(padding).left, - _customHorizontalMargin, + customHorizontalMargin, ); // Reset the surface size. diff --git a/packages/flutter/test/material/popup_menu_test.dart b/packages/flutter/test/material/popup_menu_test.dart index 1be98e7831..6d6328fe23 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart @@ -2042,7 +2042,7 @@ void main() { const double statusBarHeight = 24.0; final PopupMenuItem firstItem = choices[0]; - int _selectedValue = choices[0].value!; + int selectedValue = choices[0].value!; await tester.pumpWidget( MaterialApp( @@ -2061,10 +2061,10 @@ void main() { PopupMenuButton( onSelected: (int result) { setState(() { - _selectedValue = result; + selectedValue = result; }); }, - initialValue: _selectedValue, + initialValue: selectedValue, itemBuilder: (BuildContext context) { return choices; }, diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index 3c98bb1281..6241d3096c 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -1318,8 +1318,8 @@ void main() { testWidgets('Can switch to non-neighboring tab in nested TabBarView without crashing', (WidgetTester tester) async { // This is a regression test for https://github.com/flutter/flutter/issues/18756 - final TabController _mainTabController = TabController(length: 4, vsync: const TestVSync()); - final TabController _nestedTabController = TabController(length: 2, vsync: const TestVSync()); + final TabController mainTabController = TabController(length: 4, vsync: const TestVSync()); + final TabController nestedTabController = TabController(length: 2, vsync: const TestVSync()); await tester.pumpWidget( MaterialApp( @@ -1327,7 +1327,7 @@ void main() { appBar: AppBar( title: const Text('Exception for Nested Tabs'), bottom: TabBar( - controller: _mainTabController, + controller: mainTabController, tabs: const [ Tab(icon: Icon(Icons.add), text: 'A'), Tab(icon: Icon(Icons.add), text: 'B'), @@ -1337,10 +1337,10 @@ void main() { ), ), body: TabBarView( - controller: _mainTabController, + controller: mainTabController, children: [ Container(color: Colors.red), - _NestedTabBarContainer(tabController: _nestedTabController), + _NestedTabBarContainer(tabController: nestedTabController), Container(color: Colors.green), Container(color: Colors.indigo), ], @@ -1350,14 +1350,14 @@ void main() { ); // expect first tab to be selected - expect(_mainTabController.index, 0); + expect(mainTabController.index, 0); // tap on third tab await tester.tap(find.text('C')); await tester.pumpAndSettle(); // expect third tab to be selected without exceptions - expect(_mainTabController.index, 2); + expect(mainTabController.index, 2); }); testWidgets('TabBarView can warp when child is kept alive and contains ink', (WidgetTester tester) async { @@ -3568,19 +3568,19 @@ void main() { testWidgets('TabBar - updating to and from zero tabs', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/68962. final List tabTitles = []; - TabController _tabController = TabController(length: tabTitles.length, vsync: const TestVSync()); + TabController tabController = TabController(length: tabTitles.length, vsync: const TestVSync()); void _onTabAdd(StateSetter setState) { setState(() { tabTitles.add('Tab ${tabTitles.length + 1}'); - _tabController = TabController(length: tabTitles.length, vsync: const TestVSync()); + tabController = TabController(length: tabTitles.length, vsync: const TestVSync()); }); } void _onTabRemove(StateSetter setState) { setState(() { tabTitles.removeLast(); - _tabController = TabController(length: tabTitles.length, vsync: const TestVSync()); + tabController = TabController(length: tabTitles.length, vsync: const TestVSync()); }); } @@ -3606,7 +3606,7 @@ void main() { preferredSize: const Size.fromHeight(40.0), child: Expanded( child: TabBar( - controller: _tabController, + controller: tabController, tabs: tabTitles .map((String title) => Tab(text: title)) .toList(), diff --git a/packages/flutter/test/material/text_form_field_test.dart b/packages/flutter/test/material/text_form_field_test.dart index b4f2a1e136..9b6317d1aa 100644 --- a/packages/flutter/test/material/text_form_field_test.dart +++ b/packages/flutter/test/material/text_form_field_test.dart @@ -343,14 +343,14 @@ void main() { }); testWidgets('onFieldSubmit callbacks are called', (WidgetTester tester) async { - bool _called = false; + bool called = false; await tester.pumpWidget( MaterialApp( home: Material( child: Center( child: TextFormField( - onFieldSubmitted: (String value) { _called = true; }, + onFieldSubmitted: (String value) { called = true; }, ), ), ), @@ -360,19 +360,19 @@ void main() { await tester.showKeyboard(find.byType(TextField)); await tester.testTextInput.receiveAction(TextInputAction.done); await tester.pump(); - expect(_called, true); + expect(called, true); }); testWidgets('onChanged callbacks are called', (WidgetTester tester) async { - late String _value; + late String value; await tester.pumpWidget( MaterialApp( home: Material( child: Center( child: TextFormField( - onChanged: (String value) { - _value = value; + onChanged: (String v) { + value = v; }, ), ), @@ -382,11 +382,11 @@ void main() { await tester.enterText(find.byType(TextField), 'Soup'); await tester.pump(); - expect(_value, 'Soup'); + expect(value, 'Soup'); }); testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async { - int _validateCalled = 0; + int validateCalled = 0; await tester.pumpWidget( MaterialApp( @@ -395,7 +395,7 @@ void main() { child: TextFormField( autovalidateMode: AutovalidateMode.always, validator: (String? value) { - _validateCalled++; + validateCalled++; return null; }, ), @@ -404,14 +404,14 @@ void main() { ), ); - expect(_validateCalled, 1); + expect(validateCalled, 1); await tester.enterText(find.byType(TextField), 'a'); await tester.pump(); - expect(_validateCalled, 2); + expect(validateCalled, 2); }); testWidgets('validate is called if widget is enabled', (WidgetTester tester) async { - int _validateCalled = 0; + int validateCalled = 0; await tester.pumpWidget( MaterialApp( @@ -421,7 +421,7 @@ void main() { enabled: true, autovalidateMode: AutovalidateMode.always, validator: (String? value) { - _validateCalled += 1; + validateCalled += 1; return null; }, ), @@ -430,10 +430,10 @@ void main() { ), ); - expect(_validateCalled, 1); + expect(validateCalled, 1); await tester.enterText(find.byType(TextField), 'a'); await tester.pump(); - expect(_validateCalled, 2); + expect(validateCalled, 2); }); @@ -669,7 +669,7 @@ void main() { }); testWidgets('onChanged callbacks value and FormFieldState.value are sync', (WidgetTester tester) async { - bool _called = false; + bool called = false; late FormFieldState state; @@ -679,7 +679,7 @@ void main() { child: Center( child: TextFormField( onChanged: (String value) { - _called = true; + called = true; expect(value, state.value); }, ), @@ -692,7 +692,7 @@ void main() { await tester.enterText(find.byType(TextField), 'Soup'); - expect(_called, true); + expect(called, true); }); testWidgets('autofillHints is passed to super', (WidgetTester tester) async { @@ -713,7 +713,7 @@ void main() { }); testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async { - int _validateCalled = 0; + int validateCalled = 0; await tester.pumpWidget( MaterialApp( @@ -722,7 +722,7 @@ void main() { body: TextFormField( autovalidateMode: AutovalidateMode.onUserInteraction, validator: (String? value) { - _validateCalled++; + validateCalled++; return null; }, ), @@ -731,10 +731,10 @@ void main() { ), ); - expect(_validateCalled, 0); + expect(validateCalled, 0); await tester.enterText(find.byType(TextField), 'a'); await tester.pump(); - expect(_validateCalled, 1); + expect(validateCalled, 1); }); testWidgets('textSelectionControls is passed to super', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/theme_test.dart b/packages/flutter/test/material/theme_test.dart index 03aa0e4bfb..8b23057c01 100644 --- a/packages/flutter/test/material/theme_test.dart +++ b/packages/flutter/test/material/theme_test.dart @@ -329,16 +329,16 @@ void main() { ); testWidgets('Text geometry set in Theme has higher precedence than that of Localizations', (WidgetTester tester) async { - const double _kMagicFontSize = 4321.0; + const double kMagicFontSize = 4321.0; final ThemeData fallback = ThemeData.fallback(); final ThemeData customTheme = fallback.copyWith( primaryTextTheme: fallback.primaryTextTheme.copyWith( bodyText2: fallback.primaryTextTheme.bodyText2!.copyWith( - fontSize: _kMagicFontSize, + fontSize: kMagicFontSize, ), ), ); - expect(customTheme.primaryTextTheme.bodyText2!.fontSize, _kMagicFontSize); + expect(customTheme.primaryTextTheme.bodyText2!.fontSize, kMagicFontSize); late double actualFontSize; await tester.pumpWidget(Directionality( @@ -356,7 +356,7 @@ void main() { ), )); - expect(actualFontSize, _kMagicFontSize); + expect(actualFontSize, kMagicFontSize); }); testWidgets('Default Theme provides all basic TextStyle properties', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/toggle_buttons_test.dart b/packages/flutter/test/material/toggle_buttons_test.dart index a414e31665..98ac02d1ea 100644 --- a/packages/flutter/test/material/toggle_buttons_test.dart +++ b/packages/flutter/test/material/toggle_buttons_test.dart @@ -66,7 +66,7 @@ void main() { )).style; } - final List _isSelected = [false, true]; + final List isSelected = [false, true]; final ThemeData theme = ThemeData(); await tester.pumpWidget( Material( @@ -76,10 +76,10 @@ void main() { child: ToggleButtons( onPressed: (int index) { setState(() { - _isSelected[index] = !_isSelected[index]; + isSelected[index] = !isSelected[index]; }); }, - isSelected: _isSelected, + isSelected: isSelected, children: const [ Text('First child'), Text('Second child'), @@ -91,8 +91,8 @@ void main() { ), ); - expect(_isSelected[0], isFalse); - expect(_isSelected[1], isTrue); + expect(isSelected[0], isFalse); + expect(isSelected[1], isTrue); expect( buttonTextStyle('First child').color, theme.colorScheme.onSurface.withOpacity(0.87), @@ -105,8 +105,8 @@ void main() { await tester.tap(find.text('Second child')); await tester.pumpAndSettle(); - expect(_isSelected[0], isFalse); - expect(_isSelected[1], isFalse); + expect(isSelected[0], isFalse); + expect(isSelected[1], isFalse); expect( buttonTextStyle('First child').color, theme.colorScheme.onSurface.withOpacity(0.87), @@ -127,14 +127,14 @@ void main() { matching: find.byType(DefaultTextStyle), )).style; } - final List _isSelected = [false, true]; + final List isSelected = [false, true]; final ThemeData theme = ThemeData(); await tester.pumpWidget( Material( child: boilerplate( child: ToggleButtons( - isSelected: _isSelected, + isSelected: isSelected, children: const [ Text('First child'), Text('Second child'), @@ -144,8 +144,8 @@ void main() { ), ); - expect(_isSelected[0], isFalse); - expect(_isSelected[1], isTrue); + expect(isSelected[0], isFalse); + expect(isSelected[1], isTrue); expect( buttonTextStyle('First child').color, theme.colorScheme.onSurface.withOpacity(0.38), @@ -159,8 +159,8 @@ void main() { await tester.pumpAndSettle(); // Nothing should change - expect(_isSelected[0], isFalse); - expect(_isSelected[1], isTrue); + expect(isSelected[0], isFalse); + expect(isSelected[1], isTrue); expect( buttonTextStyle('First child').color, theme.colorScheme.onSurface.withOpacity(0.38), diff --git a/packages/flutter/test/material/tooltip_test.dart b/packages/flutter/test/material/tooltip_test.dart index 3af33ce496..8226eebe9d 100644 --- a/packages/flutter/test/material/tooltip_test.dart +++ b/packages/flutter/test/material/tooltip_test.dart @@ -507,7 +507,7 @@ void main() { }); testWidgets('Custom tooltip margin', (WidgetTester tester) async { - const double _customMarginValue = 10.0; + const double customMarginValue = 10.0; final GlobalKey key = GlobalKey(); await tester.pumpWidget( Directionality( @@ -520,7 +520,7 @@ void main() { key: key, message: tooltipText, padding: EdgeInsets.zero, - margin: const EdgeInsets.all(_customMarginValue), + margin: const EdgeInsets.all(customMarginValue), child: const SizedBox( width: 0.0, height: 0.0, @@ -539,29 +539,29 @@ void main() { _findTooltipContainer(tooltipText), ); final Offset topLeftTooltipContentInGlobal = tester.getTopLeft(find.text(tooltipText)); - expect(topLeftTooltipContentInGlobal.dx, topLeftTipInGlobal.dx + _customMarginValue); - expect(topLeftTooltipContentInGlobal.dy, topLeftTipInGlobal.dy + _customMarginValue); + expect(topLeftTooltipContentInGlobal.dx, topLeftTipInGlobal.dx + customMarginValue); + expect(topLeftTooltipContentInGlobal.dy, topLeftTipInGlobal.dy + customMarginValue); final Offset topRightTipInGlobal = tester.getTopRight( _findTooltipContainer(tooltipText), ); final Offset topRightTooltipContentInGlobal = tester.getTopRight(find.text(tooltipText)); - expect(topRightTooltipContentInGlobal.dx, topRightTipInGlobal.dx - _customMarginValue); - expect(topRightTooltipContentInGlobal.dy, topRightTipInGlobal.dy + _customMarginValue); + expect(topRightTooltipContentInGlobal.dx, topRightTipInGlobal.dx - customMarginValue); + expect(topRightTooltipContentInGlobal.dy, topRightTipInGlobal.dy + customMarginValue); final Offset bottomLeftTipInGlobal = tester.getBottomLeft( _findTooltipContainer(tooltipText), ); final Offset bottomLeftTooltipContentInGlobal = tester.getBottomLeft(find.text(tooltipText)); - expect(bottomLeftTooltipContentInGlobal.dx, bottomLeftTipInGlobal.dx + _customMarginValue); - expect(bottomLeftTooltipContentInGlobal.dy, bottomLeftTipInGlobal.dy - _customMarginValue); + expect(bottomLeftTooltipContentInGlobal.dx, bottomLeftTipInGlobal.dx + customMarginValue); + expect(bottomLeftTooltipContentInGlobal.dy, bottomLeftTipInGlobal.dy - customMarginValue); final Offset bottomRightTipInGlobal = tester.getBottomRight( _findTooltipContainer(tooltipText), ); final Offset bottomRightTooltipContentInGlobal = tester.getBottomRight(find.text(tooltipText)); - expect(bottomRightTooltipContentInGlobal.dx, bottomRightTipInGlobal.dx - _customMarginValue); - expect(bottomRightTooltipContentInGlobal.dy, bottomRightTipInGlobal.dy - _customMarginValue); + expect(bottomRightTooltipContentInGlobal.dx, bottomRightTipInGlobal.dx - customMarginValue); + expect(bottomRightTooltipContentInGlobal.dy, bottomRightTipInGlobal.dy - customMarginValue); }); testWidgets('Default tooltip message textStyle - light', (WidgetTester tester) async { diff --git a/packages/flutter/test/rendering/error_test.dart b/packages/flutter/test/rendering/error_test.dart index 12bc7272db..adc98034a6 100644 --- a/packages/flutter/test/rendering/error_test.dart +++ b/packages/flutter/test/rendering/error_test.dart @@ -21,9 +21,9 @@ void main() { ..paragraph(offset: const Offset(64.0, 96.0)), ); - final Widget _error = Builder(builder: (BuildContext context) => throw 'pillow'); + final Widget error = Builder(builder: (BuildContext context) => throw 'pillow'); - await tester.pumpWidget(Center(child: SizedBox(width: 100.0, child: _error))); + await tester.pumpWidget(Center(child: SizedBox(width: 100.0, child: error))); expect(tester.takeException(), 'pillow'); expect( find.byType(ErrorWidget), @@ -32,10 +32,10 @@ void main() { ..paragraph(offset: const Offset(0.0, 96.0)), ); - await tester.pumpWidget(Center(child: SizedBox(height: 100.0, child: _error))); + await tester.pumpWidget(Center(child: SizedBox(height: 100.0, child: error))); expect(tester.takeException(), null); - await tester.pumpWidget(Center(child: SizedBox(key: UniqueKey(), height: 100.0, child: _error))); + await tester.pumpWidget(Center(child: SizedBox(key: UniqueKey(), height: 100.0, child: error))); expect(tester.takeException(), 'pillow'); expect( find.byType(ErrorWidget), @@ -45,7 +45,7 @@ void main() { ); RenderErrorBox.minimumWidth = 800.0; - await tester.pumpWidget(Center(child: _error)); + await tester.pumpWidget(Center(child: error)); expect(tester.takeException(), 'pillow'); expect( find.byType(ErrorWidget), @@ -54,7 +54,7 @@ void main() { ..paragraph(offset: const Offset(0.0, 96.0)), ); - await tester.pumpWidget(Center(child: _error)); + await tester.pumpWidget(Center(child: error)); expect(tester.takeException(), null); expect( find.byType(ErrorWidget), @@ -64,7 +64,7 @@ void main() { ); RenderErrorBox.backgroundColor = const Color(0xFF112233); - await tester.pumpWidget(Center(child: _error)); + await tester.pumpWidget(Center(child: error)); expect(tester.takeException(), null); expect( find.byType(ErrorWidget), diff --git a/packages/flutter/test/rendering/mouse_tracker_cursor_test.dart b/packages/flutter/test/rendering/mouse_tracker_cursor_test.dart index 58fe781d0c..c3c8a27a4b 100644 --- a/packages/flutter/test/rendering/mouse_tracker_cursor_test.dart +++ b/packages/flutter/test/rendering/mouse_tracker_cursor_test.dart @@ -16,8 +16,8 @@ typedef MethodCallHandler = Future Function(MethodCall call); typedef SimpleAnnotationFinder = Iterable Function(Offset offset); void main() { - final TestMouseTrackerFlutterBinding _binding = TestMouseTrackerFlutterBinding(); - MethodCallHandler? _methodCallHandler; + final TestMouseTrackerFlutterBinding binding = TestMouseTrackerFlutterBinding(); + MethodCallHandler? methodCallHandler; // Only one of `logCursors` and `cursorHandler` should be specified. void _setUpMouseTracker({ @@ -26,14 +26,14 @@ void main() { MethodCallHandler? cursorHandler, }) { assert(logCursors == null || cursorHandler == null); - _methodCallHandler = logCursors != null + methodCallHandler = logCursors != null ? (MethodCall call) async { logCursors.add(_CursorUpdateDetails.wrap(call)); return; } : cursorHandler; - _binding.setHitTest((BoxHitTestResult result, Offset position) { + binding.setHitTest((BoxHitTestResult result, Offset position) { for (final HitTestTarget target in annotationFinder(position)) { result.addWithRawTransform( transform: Matrix4.identity(), @@ -55,17 +55,17 @@ void main() { } setUp(() { - _binding.postFrameCallbacks.clear(); - _binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.mouseCursor, (MethodCall call) async { - if (_methodCallHandler != null) { - return _methodCallHandler!(call); + binding.postFrameCallbacks.clear(); + binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.mouseCursor, (MethodCall call) async { + if (methodCallHandler != null) { + return methodCallHandler!(call); } return null; }); }); tearDown(() { - _binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.mouseCursor, null); + binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.mouseCursor, null); }); test('Should work on platforms that does not support mouse cursor', () async { @@ -221,8 +221,8 @@ void main() { // Synthesize a new frame while changing annotation annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing); - _binding.scheduleMouseTrackerPostFrameCheck(); - _binding.flushPostFrameCallbacks(Duration.zero); + binding.scheduleMouseTrackerPostFrameCheck(); + binding.flushPostFrameCallbacks(Duration.zero); expect(logCursors, <_CursorUpdateDetails>[ _CursorUpdateDetails.activateSystemCursor(device: 0, kind: SystemMouseCursors.grabbing.kind), @@ -231,7 +231,7 @@ void main() { // Synthesize a new frame without changing annotation annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing); - _binding.scheduleMouseTrackerPostFrameCheck(); + binding.scheduleMouseTrackerPostFrameCheck(); expect(logCursors, <_CursorUpdateDetails>[]); logCursors.clear(); diff --git a/packages/flutter/test/rendering/mouse_tracker_test.dart b/packages/flutter/test/rendering/mouse_tracker_test.dart index 4d2a55727d..3adbfd9ada 100644 --- a/packages/flutter/test/rendering/mouse_tracker_test.dart +++ b/packages/flutter/test/rendering/mouse_tracker_test.dart @@ -16,9 +16,9 @@ MouseTracker get _mouseTracker => RendererBinding.instance!.mouseTracker; typedef SimpleAnnotationFinder = Iterable Function(Offset offset); void main() { - final TestMouseTrackerFlutterBinding _binding = TestMouseTrackerFlutterBinding(); + final TestMouseTrackerFlutterBinding binding = TestMouseTrackerFlutterBinding(); void _setUpMouseAnnotationFinder(SimpleAnnotationFinder annotationFinder) { - _binding.setHitTest((BoxHitTestResult result, Offset position) { + binding.setHitTest((BoxHitTestResult result, Offset position) { for (final TestAnnotationEntry entry in annotationFinder(position)) { result.addWithRawTransform( transform: entry.transform, @@ -70,7 +70,7 @@ void main() { } setUp(() { - _binding.postFrameCallbacks.clear(); + binding.postFrameCallbacks.clear(); }); final Matrix4 translate10by20 = Matrix4.translationValues(10, 20, 0); @@ -270,10 +270,10 @@ void main() { // Adding an annotation should trigger Enter event. isInHitRegion = true; - _binding.scheduleMouseTrackerPostFrameCheck(); - expect(_binding.postFrameCallbacks, hasLength(1)); + binding.scheduleMouseTrackerPostFrameCheck(); + expect(binding.postFrameCallbacks, hasLength(1)); - _binding.flushPostFrameCallbacks(Duration.zero); + binding.flushPostFrameCallbacks(Duration.zero); expect(events, _equalToEventsOnCriticalFields([ EventMatcher(const PointerEnterEvent(position: Offset(0, 100)).transformed(translate10by20)), ])); @@ -281,14 +281,14 @@ void main() { // Removing an annotation should trigger events. isInHitRegion = false; - _binding.scheduleMouseTrackerPostFrameCheck(); - expect(_binding.postFrameCallbacks, hasLength(1)); + binding.scheduleMouseTrackerPostFrameCheck(); + expect(binding.postFrameCallbacks, hasLength(1)); - _binding.flushPostFrameCallbacks(Duration.zero); + binding.flushPostFrameCallbacks(Duration.zero); expect(events, _equalToEventsOnCriticalFields([ EventMatcher(const PointerExitEvent(position: Offset(0.0, 100.0)).transformed(translate10by20)), ])); - expect(_binding.postFrameCallbacks, hasLength(0)); + expect(binding.postFrameCallbacks, hasLength(0)); }); test('should correctly handle when the annotation moves in or out of the pointer', () { @@ -316,29 +316,29 @@ void main() { // During a frame, the annotation moves into the pointer. isInHitRegion = true; - expect(_binding.postFrameCallbacks, hasLength(0)); - _binding.scheduleMouseTrackerPostFrameCheck(); - expect(_binding.postFrameCallbacks, hasLength(1)); + expect(binding.postFrameCallbacks, hasLength(0)); + binding.scheduleMouseTrackerPostFrameCheck(); + expect(binding.postFrameCallbacks, hasLength(1)); - _binding.flushPostFrameCallbacks(Duration.zero); + binding.flushPostFrameCallbacks(Duration.zero); expect(events, _equalToEventsOnCriticalFields([ EventMatcher(const PointerEnterEvent(position: Offset(0.0, 100.0)).transformed(translate10by20)), ])); events.clear(); - expect(_binding.postFrameCallbacks, hasLength(0)); + expect(binding.postFrameCallbacks, hasLength(0)); // During a frame, the annotation moves out of the pointer. isInHitRegion = false; - expect(_binding.postFrameCallbacks, hasLength(0)); - _binding.scheduleMouseTrackerPostFrameCheck(); - expect(_binding.postFrameCallbacks, hasLength(1)); + expect(binding.postFrameCallbacks, hasLength(0)); + binding.scheduleMouseTrackerPostFrameCheck(); + expect(binding.postFrameCallbacks, hasLength(1)); - _binding.flushPostFrameCallbacks(Duration.zero); + binding.flushPostFrameCallbacks(Duration.zero); expect(events, _equalToEventsOnCriticalFields([ EventMatcher(const PointerExitEvent(position: Offset(0.0, 100.0)).transformed(translate10by20)), ])); - expect(_binding.postFrameCallbacks, hasLength(0)); + expect(binding.postFrameCallbacks, hasLength(0)); }); test('should correctly handle when the pointer is added or removed on the annotation', () { @@ -363,7 +363,7 @@ void main() { _pointerData(PointerChange.add, const Offset(0.0, 100.0)), ])); - expect(_binding.postFrameCallbacks, hasLength(0)); + expect(binding.postFrameCallbacks, hasLength(0)); expect(events, _equalToEventsOnCriticalFields([ EventMatcher(const PointerEnterEvent(position: Offset(0.0, 100.0)).transformed(translate10by20)), ])); @@ -373,7 +373,7 @@ void main() { ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: [ _pointerData(PointerChange.remove, const Offset(0.0, 100.0)), ])); - expect(_binding.postFrameCallbacks, hasLength(0)); + expect(binding.postFrameCallbacks, hasLength(0)); expect(events, _equalToEventsOnCriticalFields([ EventMatcher(const PointerExitEvent(position: Offset(0.0, 100.0)).transformed(translate10by20)), ])); @@ -399,7 +399,7 @@ void main() { ])); addTearDown(() => dispatchRemoveDevice()); - expect(_binding.postFrameCallbacks, hasLength(0)); + expect(binding.postFrameCallbacks, hasLength(0)); events.clear(); // Moves the mouse into the region. Should trigger Enter. @@ -407,7 +407,7 @@ void main() { ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: [ _pointerData(PointerChange.hover, const Offset(0.0, 100.0)), ])); - expect(_binding.postFrameCallbacks, hasLength(0)); + expect(binding.postFrameCallbacks, hasLength(0)); expect(events, _equalToEventsOnCriticalFields([ EventMatcher(const PointerEnterEvent(position: Offset(0.0, 100.0)).transformed(translate10by20)), EventMatcher(const PointerHoverEvent(position: Offset(0.0, 100.0)).transformed(translate10by20)), @@ -419,7 +419,7 @@ void main() { ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: [ _pointerData(PointerChange.hover, const Offset(200.0, 100.0)), ])); - expect(_binding.postFrameCallbacks, hasLength(0)); + expect(binding.postFrameCallbacks, hasLength(0)); expect(events, _equalToEventsOnCriticalFields([ EventMatcher(const PointerExitEvent(position: Offset(200.0, 100.0)).transformed(translate10by20)), ])); @@ -435,7 +435,7 @@ void main() { ])); expect(_mouseTracker.mouseIsConnected, isFalse); - expect(_binding.postFrameCallbacks, hasLength(0)); + expect(binding.postFrameCallbacks, hasLength(0)); }); test('should not flip out if not all mouse events are listened to', () { diff --git a/packages/flutter/test/widgets/basic_test.dart b/packages/flutter/test/widgets/basic_test.dart index ab1f3e19d4..049be02ed8 100644 --- a/packages/flutter/test/widgets/basic_test.dart +++ b/packages/flutter/test/widgets/basic_test.dart @@ -154,7 +154,7 @@ void main() { group('FractionalTranslation', () { testWidgets('hit test - entirely inside the bounding box', (WidgetTester tester) async { final GlobalKey key1 = GlobalKey(); - bool _pointerDown = false; + bool pointerDown = false; await tester.pumpWidget( Center( @@ -162,7 +162,7 @@ void main() { translation: Offset.zero, child: Listener( onPointerDown: (PointerDownEvent event) { - _pointerDown = true; + pointerDown = true; }, child: SizedBox( key: key1, @@ -176,14 +176,14 @@ void main() { ), ), ); - expect(_pointerDown, isFalse); + expect(pointerDown, isFalse); await tester.tap(find.byKey(key1)); - expect(_pointerDown, isTrue); + expect(pointerDown, isTrue); }); testWidgets('hit test - partially inside the bounding box', (WidgetTester tester) async { final GlobalKey key1 = GlobalKey(); - bool _pointerDown = false; + bool pointerDown = false; await tester.pumpWidget( Center( @@ -191,7 +191,7 @@ void main() { translation: const Offset(0.5, 0.5), child: Listener( onPointerDown: (PointerDownEvent event) { - _pointerDown = true; + pointerDown = true; }, child: SizedBox( key: key1, @@ -205,14 +205,14 @@ void main() { ), ), ); - expect(_pointerDown, isFalse); + expect(pointerDown, isFalse); await tester.tap(find.byKey(key1)); - expect(_pointerDown, isTrue); + expect(pointerDown, isTrue); }); testWidgets('hit test - completely outside the bounding box', (WidgetTester tester) async { final GlobalKey key1 = GlobalKey(); - bool _pointerDown = false; + bool pointerDown = false; await tester.pumpWidget( Center( @@ -220,7 +220,7 @@ void main() { translation: const Offset(1.0, 1.0), child: Listener( onPointerDown: (PointerDownEvent event) { - _pointerDown = true; + pointerDown = true; }, child: SizedBox( key: key1, @@ -234,9 +234,9 @@ void main() { ), ), ); - expect(_pointerDown, isFalse); + expect(pointerDown, isFalse); await tester.tap(find.byKey(key1)); - expect(_pointerDown, isTrue); + expect(pointerDown, isTrue); }); testWidgets('semantics bounds are updated', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/fitted_box_test.dart b/packages/flutter/test/widgets/fitted_box_test.dart index a5b1cdc52b..591379c1a6 100644 --- a/packages/flutter/test/widgets/fitted_box_test.dart +++ b/packages/flutter/test/widgets/fitted_box_test.dart @@ -444,7 +444,7 @@ void main() { testWidgets('Big child into small fitted box - hit testing', (WidgetTester tester) async { final GlobalKey key1 = GlobalKey(); - bool _pointerDown = false; + bool pointerDown = false; await tester.pumpWidget( Center( child: SizedBox( @@ -457,7 +457,7 @@ void main() { height: 1000.0, child: Listener( onPointerDown: (PointerDownEvent event) { - _pointerDown = true; + pointerDown = true; }, child: Container( key: key1, @@ -469,9 +469,9 @@ void main() { ), ), ); - expect(_pointerDown, isFalse); + expect(pointerDown, isFalse); await tester.tap(find.byKey(key1)); - expect(_pointerDown, isTrue); + expect(pointerDown, isTrue); }); testWidgets('Can set and update clipBehavior', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/image_icon_test.dart b/packages/flutter/test/widgets/image_icon_test.dart index 2b8e18b508..0d4709406a 100644 --- a/packages/flutter/test/widgets/image_icon_test.dart +++ b/packages/flutter/test/widgets/image_icon_test.dart @@ -10,10 +10,10 @@ import '../painting/mocks_for_image_cache.dart'; void main() { - late ImageProvider _image; + late ImageProvider image; setUpAll(() async { - _image = TestImageProvider( + image = TestImageProvider( 21, 42, image: await createTestImage(width: 10, height: 10), @@ -23,7 +23,7 @@ void main() { testWidgets('ImageIcon sizing - no theme, default size', (WidgetTester tester) async { await tester.pumpWidget( Center( - child: ImageIcon(_image), + child: ImageIcon(image), ), ); @@ -37,13 +37,12 @@ void main() { Center( child: IconTheme( data: const IconThemeData(opacity: 0.5), - child: ImageIcon(_image), + child: ImageIcon(image), ), ), ); - final Image image = tester.widget(find.byType(Image)); - expect(image.color!.alpha, equals(128)); + expect(tester.widget(find.byType(Image)).color!.alpha, equals(128)); }); testWidgets('ImageIcon sizing - no theme, explicit size', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/inherited_model_test.dart b/packages/flutter/test/widgets/inherited_model_test.dart index 313dadd337..feaac0f6b3 100644 --- a/packages/flutter/test/widgets/inherited_model_test.dart +++ b/packages/flutter/test/widgets/inherited_model_test.dart @@ -74,9 +74,9 @@ class _ShowABCFieldState extends State { void main() { testWidgets('InheritedModel basics', (WidgetTester tester) async { - int _a = 0; - int _b = 1; - int _c = 2; + int a = 0; + int b = 1; + int c = 2; final Widget abcPage = StatefulBuilder( builder: (BuildContext context, StateSetter setState) { @@ -97,9 +97,9 @@ void main() { body: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return ABCModel( - a: _a, - b: _b, - c: _c, + a: a, + b: b, + c: c, child: Center( child: Column( mainAxisSize: MainAxisSize.min, @@ -114,7 +114,7 @@ void main() { // Rebuilds the ABCModel which triggers a rebuild // of showA because showA depends on the 'a' aspect // of the ABCModel. - setState(() { _a += 1; }); + setState(() { a += 1; }); }, ), ElevatedButton( @@ -123,7 +123,7 @@ void main() { // Rebuilds the ABCModel which triggers a rebuild // of showB because showB depends on the 'b' aspect // of the ABCModel. - setState(() { _b += 1; }); + setState(() { b += 1; }); }, ), ElevatedButton( @@ -132,7 +132,7 @@ void main() { // Rebuilds the ABCModel which triggers a rebuild // of showC because showC depends on the 'c' aspect // of the ABCModel. - setState(() { _c += 1; }); + setState(() { c += 1; }); }, ), ], @@ -206,9 +206,9 @@ void main() { }); testWidgets('Inner InheritedModel shadows the outer one', (WidgetTester tester) async { - int _a = 0; - int _b = 1; - int _c = 2; + int a = 0; + int b = 1; + int c = 2; // Same as in abcPage in the "InheritedModel basics" test except: // there are two ABCModels and the inner model's "a" and "b" @@ -234,12 +234,12 @@ void main() { body: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return ABCModel( // The "outer" model - a: _a, - b: _b, - c: _c, + a: a, + b: b, + c: c, child: ABCModel( // The "inner" model - a: 100 + _a, - b: 100 + _b, + a: 100 + a, + b: 100 + b, aspects: const {'a'}, child: Center( child: Column( @@ -254,19 +254,19 @@ void main() { ElevatedButton( child: const Text('Increment a'), onPressed: () { - setState(() { _a += 1; }); + setState(() { a += 1; }); }, ), ElevatedButton( child: const Text('Increment b'), onPressed: () { - setState(() { _b += 1; }); + setState(() { b += 1; }); }, ), ElevatedButton( child: const Text('Increment c'), onPressed: () { - setState(() { _c += 1; }); + setState(() { c += 1; }); }, ), ], @@ -324,10 +324,10 @@ void main() { }); testWidgets('InheritedModel inner models supported aspect change', (WidgetTester tester) async { - int _a = 0; - int _b = 1; - int _c = 2; - Set? _innerModelAspects = {'a'}; + int a = 0; + int b = 1; + int c = 2; + Set? innerModelAspects = {'a'}; // Same as in abcPage in the "Inner InheritedModel shadows the outer one" // test except: the "Add b aspect" changes adds 'b' to the set of @@ -351,13 +351,13 @@ void main() { body: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return ABCModel( // The "outer" model - a: _a, - b: _b, - c: _c, + a: a, + b: b, + c: c, child: ABCModel( // The "inner" model - a: 100 + _a, - b: 100 + _b, - aspects: _innerModelAspects, + a: 100 + a, + b: 100 + b, + aspects: innerModelAspects, child: Center( child: Column( mainAxisSize: MainAxisSize.min, @@ -371,19 +371,19 @@ void main() { ElevatedButton( child: const Text('Increment a'), onPressed: () { - setState(() { _a += 1; }); + setState(() { a += 1; }); }, ), ElevatedButton( child: const Text('Increment b'), onPressed: () { - setState(() { _b += 1; }); + setState(() { b += 1; }); }, ), ElevatedButton( child: const Text('Increment c'), onPressed: () { - setState(() { _c += 1; }); + setState(() { c += 1; }); }, ), ElevatedButton( @@ -405,14 +405,14 @@ void main() { }, ); - _innerModelAspects = {'a'}; + innerModelAspects = {'a'}; await tester.pumpWidget(MaterialApp(home: abcPage)); expect(find.text('a: 100 [0]'), findsOneWidget); // showA depends on the inner model expect(find.text('b: 1 [0]'), findsOneWidget); // showB depends on the outer model expect(find.text('c: 2 [0]'), findsOneWidget); expect(find.text('a: 100 b: 101 c: null'), findsOneWidget); // inner model's a, b, c - _innerModelAspects = {'a', 'b'}; + innerModelAspects = {'a', 'b'}; await tester.tap(find.text('rebuild')); await tester.pumpAndSettle(); expect(find.text('a: 100 [1]'), findsOneWidget); // rebuilt showA still depend on the inner model @@ -447,7 +447,7 @@ void main() { expect(find.text('c: 3 [2]'), findsOneWidget); // rebuilt showC still depends on the outer model expect(find.text('a: 101 b: 102 c: null'), findsOneWidget); - _innerModelAspects = {'a', 'b', 'c'}; + innerModelAspects = {'a', 'b', 'c'}; await tester.tap(find.text('rebuild')); await tester.pumpAndSettle(); expect(find.text('a: 101 [3]'), findsOneWidget); // rebuilt showA still depend on the inner model @@ -456,7 +456,7 @@ void main() { expect(find.text('a: 101 b: 102 c: null'), findsOneWidget); // inner model's a, b, c // Now the inner model supports no aspects - _innerModelAspects = {}; + innerModelAspects = {}; await tester.tap(find.text('rebuild')); await tester.pumpAndSettle(); expect(find.text('a: 1 [4]'), findsOneWidget); // rebuilt showA now depends on the outer model @@ -465,7 +465,7 @@ void main() { expect(find.text('a: 101 b: 102 c: null'), findsOneWidget); // inner model's a, b, c // Now the inner model supports all aspects - _innerModelAspects = null; + innerModelAspects = null; await tester.tap(find.text('rebuild')); await tester.pumpAndSettle(); expect(find.text('a: 101 [5]'), findsOneWidget); // rebuilt showA now depends on the inner model diff --git a/packages/flutter/test/widgets/nested_scroll_view_test.dart b/packages/flutter/test/widgets/nested_scroll_view_test.dart index 8bf26e481f..44a046e034 100644 --- a/packages/flutter/test/widgets/nested_scroll_view_test.dart +++ b/packages/flutter/test/widgets/nested_scroll_view_test.dart @@ -470,14 +470,14 @@ void main() { testWidgets('NestedScrollView and internal scrolling', (WidgetTester tester) async { debugDisableShadows = false; - const List _tabs = ['Hello', 'World']; + const List tabs = ['Hello', 'World']; int buildCount = 0; await tester.pumpWidget( MaterialApp(home: Material(child: // THE FOLLOWING SECTION IS FROM THE NestedScrollView DOCUMENTATION // (EXCEPT FOR THE CHANGES TO THE buildCount COUNTER) DefaultTabController( - length: _tabs.length, // This is the number of tabs. + length: tabs.length, // This is the number of tabs. child: NestedScrollView( dragStartBehavior: DragStartBehavior.down, headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { @@ -510,7 +510,7 @@ void main() { bottom: TabBar( // These are the widgets to put in each tab in the tab // bar. - tabs: _tabs.map((String name) => Tab(text: name)).toList(), + tabs: tabs.map((String name) => Tab(text: name)).toList(), dragStartBehavior: DragStartBehavior.down, ), ), @@ -520,7 +520,7 @@ void main() { body: TabBarView( dragStartBehavior: DragStartBehavior.down, // These are the contents of the tab views, below the tabs. - children: _tabs.map((String name) { + children: tabs.map((String name) { return SafeArea( top: false, bottom: false, diff --git a/packages/flutter/test/widgets/routes_test.dart b/packages/flutter/test/widgets/routes_test.dart index 2c22ed83d4..8758dcbf1d 100644 --- a/packages/flutter/test/widgets/routes_test.dart +++ b/packages/flutter/test/widgets/routes_test.dart @@ -1384,9 +1384,9 @@ void main() { ), )); - final CurveTween _defaultBarrierTween = CurveTween(curve: Curves.ease); + final CurveTween defaultBarrierTween = CurveTween(curve: Curves.ease); int _getExpectedBarrierTweenAlphaValue(double t) { - return Color.getAlphaFromOpacity(_defaultBarrierTween.transform(t)); + return Color.getAlphaFromOpacity(defaultBarrierTween.transform(t)); } await tester.tap(find.text('X')); @@ -1447,9 +1447,9 @@ void main() { ), )); - final CurveTween _customBarrierTween = CurveTween(curve: Curves.linear); + final CurveTween customBarrierTween = CurveTween(curve: Curves.linear); int _getExpectedBarrierTweenAlphaValue(double t) { - return Color.getAlphaFromOpacity(_customBarrierTween.transform(t)); + return Color.getAlphaFromOpacity(customBarrierTween.transform(t)); } await tester.tap(find.text('X')); @@ -1510,9 +1510,9 @@ void main() { ), )); - final CurveTween _defaultBarrierTween = CurveTween(curve: Curves.ease); + final CurveTween defaultBarrierTween = CurveTween(curve: Curves.ease); int _getExpectedBarrierTweenAlphaValue(double t) { - return Color.getAlphaFromOpacity(_defaultBarrierTween.transform(t)); + return Color.getAlphaFromOpacity(defaultBarrierTween.transform(t)); } await tester.tap(find.text('X')); diff --git a/packages/flutter/test/widgets/transform_test.dart b/packages/flutter/test/widgets/transform_test.dart index 7c2a3d8963..621a4ee77f 100644 --- a/packages/flutter/test/widgets/transform_test.dart +++ b/packages/flutter/test/widgets/transform_test.dart @@ -341,7 +341,7 @@ void main() { testWidgets('Translated child into translated box - hit test', (WidgetTester tester) async { final GlobalKey key1 = GlobalKey(); - bool _pointerDown = false; + bool pointerDown = false; await tester.pumpWidget( Transform.translate( offset: const Offset(100.0, 50.0), @@ -349,7 +349,7 @@ void main() { offset: const Offset(1000.0, 1000.0), child: Listener( onPointerDown: (PointerDownEvent event) { - _pointerDown = true; + pointerDown = true; }, child: Container( key: key1, @@ -359,9 +359,9 @@ void main() { ), ), ); - expect(_pointerDown, isFalse); + expect(pointerDown, isFalse); await tester.tap(find.byKey(key1)); - expect(_pointerDown, isTrue); + expect(pointerDown, isTrue); }); Widget _generateTransform(bool needsCompositing, double angle) { @@ -588,9 +588,9 @@ void main() { }); testWidgets("Transform.scale() scales widget uniformly with 'scale' parameter", (WidgetTester tester) async { - const double _scale = 1.5; - const double _height = 100; - const double _width = 150; + const double scale = 1.5; + const double height = 100; + const double width = 150; await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, child: SizedBox( @@ -598,26 +598,26 @@ void main() { width: 400, child: Center( child: Transform.scale( - scale: _scale, + scale: scale, child: Container( - height: _height, - width: _width, + height: height, + width: width, decoration: const BoxDecoration(), ), ), ), ))); - const Size _target = Size(_width * _scale, _height * _scale); + const Size target = Size(width * scale, height * scale); - expect(tester.getBottomRight(find.byType(Container)), _target.bottomRight(tester.getTopLeft(find.byType(Container)))); + expect(tester.getBottomRight(find.byType(Container)), target.bottomRight(tester.getTopLeft(find.byType(Container)))); }); testWidgets("Transform.scale() scales widget according to 'scaleX' and 'scaleY'", (WidgetTester tester) async { - const double _scaleX = 1.5; - const double _scaleY = 1.2; - const double _height = 100; - const double _width = 150; + const double scaleX = 1.5; + const double scaleY = 1.2; + const double height = 100; + const double width = 150; await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, child: SizedBox( @@ -625,20 +625,20 @@ void main() { width: 400, child: Center( child: Transform.scale( - scaleX: _scaleX, - scaleY: _scaleY, + scaleX: scaleX, + scaleY: scaleY, child: Container( - height: _height, - width: _width, + height: height, + width: width, decoration: const BoxDecoration(), ), ), ), ))); - const Size _target = Size(_width * _scaleX, _height * _scaleY); + const Size target = Size(width * scaleX, height * scaleY); - expect(tester.getBottomRight(find.byType(Container)), _target.bottomRight(tester.getTopLeft(find.byType(Container)))); + expect(tester.getBottomRight(find.byType(Container)), target.bottomRight(tester.getTopLeft(find.byType(Container)))); }); } diff --git a/packages/flutter_driver/lib/src/common/handler_factory.dart b/packages/flutter_driver/lib/src/common/handler_factory.dart index 8840802bb2..b1f91cb86d 100644 --- a/packages/flutter_driver/lib/src/common/handler_factory.dart +++ b/packages/flutter_driver/lib/src/common/handler_factory.dart @@ -361,23 +361,23 @@ mixin CommandHandlerFactory { ))); } - Future _scroll(Command command, WidgetController _prober, CreateFinderFactory finderFactory) async { + Future _scroll(Command command, WidgetController prober, CreateFinderFactory finderFactory) async { final Scroll scrollCommand = command as Scroll; final Finder target = await waitForElement(finderFactory.createFinder(scrollCommand.finder)); final int totalMoves = scrollCommand.duration.inMicroseconds * scrollCommand.frequency ~/ Duration.microsecondsPerSecond; final Offset delta = Offset(scrollCommand.dx, scrollCommand.dy) / totalMoves.toDouble(); final Duration pause = scrollCommand.duration ~/ totalMoves; - final Offset startLocation = _prober.getCenter(target); + final Offset startLocation = prober.getCenter(target); Offset currentLocation = startLocation; final TestPointer pointer = TestPointer(); - _prober.binding.handlePointerEvent(pointer.down(startLocation)); + prober.binding.handlePointerEvent(pointer.down(startLocation)); await Future.value(); // so that down and move don't happen in the same microtask for (int moves = 0; moves < totalMoves; moves += 1) { currentLocation = currentLocation + delta; - _prober.binding.handlePointerEvent(pointer.move(currentLocation)); + prober.binding.handlePointerEvent(pointer.move(currentLocation)); await Future.delayed(pause); } - _prober.binding.handlePointerEvent(pointer.up()); + prober.binding.handlePointerEvent(pointer.up()); return Result.empty; } diff --git a/packages/flutter_test/lib/src/animation_sheet.dart b/packages/flutter_test/lib/src/animation_sheet.dart index b7417d5228..4eb44e478a 100644 --- a/packages/flutter_test/lib/src/animation_sheet.dart +++ b/packages/flutter_test/lib/src/animation_sheet.dart @@ -463,7 +463,7 @@ class _CellSheet extends StatelessWidget { final List children; @override - Widget build(BuildContext _context) { + Widget build(BuildContext context) { return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { final double rowWidth = constraints.biggest.width; final int cellsPerRow = (rowWidth / cellSize.width).floor(); diff --git a/packages/flutter_test/lib/src/binding.dart b/packages/flutter_test/lib/src/binding.dart index d3f5cac9ca..78b9d4ab3c 100644 --- a/packages/flutter_test/lib/src/binding.dart +++ b/packages/flutter_test/lib/src/binding.dart @@ -662,19 +662,19 @@ abstract class TestWidgetsFlutterBinding extends BindingBase assert(inTest); _oldExceptionHandler = FlutterError.onError; _oldStackTraceDemangler = FlutterError.demangleStackTrace; - int _exceptionCount = 0; // number of un-taken exceptions + int exceptionCount = 0; // number of un-taken exceptions FlutterError.onError = (FlutterErrorDetails details) { if (_pendingExceptionDetails != null) { debugPrint = debugPrintOverride; // just in case the test overrides it -- otherwise we won't see the errors! - if (_exceptionCount == 0) { - _exceptionCount = 2; + if (exceptionCount == 0) { + exceptionCount = 2; FlutterError.dumpErrorToConsole(_pendingExceptionDetails!, forceReport: true); } else { - _exceptionCount += 1; + exceptionCount += 1; } FlutterError.dumpErrorToConsole(details, forceReport: true); _pendingExceptionDetails = FlutterErrorDetails( - exception: 'Multiple exceptions ($_exceptionCount) were detected during the running of the current test, and at least one was unexpected.', + exception: 'Multiple exceptions ($exceptionCount) were detected during the running of the current test, and at least one was unexpected.', library: 'Flutter test framework', ); } else { diff --git a/packages/flutter_test/test/accessibility_test.dart b/packages/flutter_test/test/accessibility_test.dart index fa12a47bcd..3c3ff618b2 100644 --- a/packages/flutter_test/test/accessibility_test.dart +++ b/packages/flutter_test/test/accessibility_test.dart @@ -221,9 +221,9 @@ void main() { Widget _row(List widgets) => _boilerplate(Row(children: widgets)); - final Finder _findIcons = find.byWidgetPredicate((Widget widget) => widget is Icon); - final Finder _findTexts = find.byWidgetPredicate((Widget widget) => widget is Text); - final Finder _findIconsAndTexts = find.byWidgetPredicate((Widget widget) => widget is Icon || widget is Text); + final Finder findIcons = find.byWidgetPredicate((Widget widget) => widget is Icon); + final Finder findTexts = find.byWidgetPredicate((Widget widget) => widget is Text); + final Finder findIconsAndTexts = find.byWidgetPredicate((Widget widget) => widget is Icon || widget is Text); testWidgets('Black icons on white background', (WidgetTester tester) async { await tester.pumpWidget(_row([ @@ -231,7 +231,7 @@ void main() { _icon(color: Colors.black, background: Colors.white), ])); - await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); + await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons))); }); testWidgets('Black icons on black background', (WidgetTester tester) async { @@ -240,7 +240,7 @@ void main() { _icon(color: Colors.black, background: Colors.black), ])); - await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); + await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findIcons))); }); testWidgets('White icons on black background ("dark mode")', (WidgetTester tester) async { @@ -249,7 +249,7 @@ void main() { _icon(color: Colors.white, background: Colors.black), ])); - await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); + await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons))); }); testWidgets('Using different icons', (WidgetTester tester) async { @@ -260,7 +260,7 @@ void main() { _icon(color: Colors.black, background: Colors.white, icon: Icons.beach_access), ])); - await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); + await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons))); }); testWidgets('One invalid instance fails entire test', (WidgetTester tester) async { @@ -269,7 +269,7 @@ void main() { _icon(color: Colors.black, background: Colors.black), ])); - await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); + await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findIcons))); }); testWidgets('White on different colors, passing', (WidgetTester tester) async { @@ -280,7 +280,7 @@ void main() { _icon(color: Colors.white, background: Colors.purple[800]!, icon: Icons.beach_access), ])); - await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); + await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons))); }); testWidgets('White on different colors, failing', (WidgetTester tester) async { @@ -291,13 +291,13 @@ void main() { _icon(color: Colors.white, background: Colors.purple[800]!, icon: Icons.beach_access), ])); - await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); + await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findIcons))); }); testWidgets('Absence of icons, passing', (WidgetTester tester) async { await tester.pumpWidget(_row([])); - await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); + await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons))); }); testWidgets('Absence of icons, passing - 2nd test', (WidgetTester tester) async { @@ -306,7 +306,7 @@ void main() { _text(color: Colors.black, background: Colors.black), ])); - await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); + await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons))); }); testWidgets('Guideline ignores widgets of other types', (WidgetTester tester) async { @@ -317,9 +317,9 @@ void main() { _text(color: Colors.black, background: Colors.black), ])); - await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); - await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findTexts))); - await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIconsAndTexts))); + await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons))); + await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findTexts))); + await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findIconsAndTexts))); }); testWidgets('Custom minimum ratio - Icons', (WidgetTester tester) async { @@ -328,8 +328,8 @@ void main() { _icon(color: Colors.black, background: Colors.white), ])); - await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); - await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons, minimumRatio: 3.0))); + await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findIcons))); + await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons, minimumRatio: 3.0))); }); testWidgets('Custom minimum ratio - Texts', (WidgetTester tester) async { @@ -338,8 +338,8 @@ void main() { _text(color: Colors.black, background: Colors.white), ])); - await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findTexts))); - await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findTexts, minimumRatio: 3.0))); + await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findTexts))); + await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findTexts, minimumRatio: 3.0))); }); testWidgets('Custom minimum ratio - Different standards for icons and texts', (WidgetTester tester) async { @@ -350,8 +350,8 @@ void main() { _text(color: Colors.black, background: Colors.white), ])); - await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); - await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findTexts, minimumRatio: 3.0))); + await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findIcons))); + await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findTexts, minimumRatio: 3.0))); }); }); diff --git a/packages/flutter_tools/lib/src/commands/ide_config.dart b/packages/flutter_tools/lib/src/commands/ide_config.dart index 21b0863454..25fd2f213d 100644 --- a/packages/flutter_tools/lib/src/commands/ide_config.dart +++ b/packages/flutter_tools/lib/src/commands/ide_config.dart @@ -132,11 +132,11 @@ class IdeConfigCommand extends FlutterCommand { } // Skip files we aren't interested in. - final RegExp _trackedIdeaFileRegExp = RegExp( + final RegExp trackedIdeaFileRegExp = RegExp( r'(\.name|modules.xml|vcs.xml)$', ); final bool isATrackedIdeaFile = _hasDirectoryInPath(srcFile, '.idea') && - (_trackedIdeaFileRegExp.hasMatch(relativePath) || + (trackedIdeaFileRegExp.hasMatch(relativePath) || _hasDirectoryInPath(srcFile, 'runConfigurations')); final bool isAnImlOutsideIdea = !isATrackedIdeaFile && srcFile.path.endsWith('.iml'); if (!isATrackedIdeaFile && !isAnImlOutsideIdea) { diff --git a/packages/flutter_tools/lib/src/debug_adapters/server.dart b/packages/flutter_tools/lib/src/debug_adapters/server.dart index 1a149d2c73..7780ea821c 100644 --- a/packages/flutter_tools/lib/src/debug_adapters/server.dart +++ b/packages/flutter_tools/lib/src/debug_adapters/server.dart @@ -21,8 +21,8 @@ import 'flutter_test_adapter.dart'; /// adapters. class DapServer { DapServer( - Stream> _input, - StreamSink> _output, { + Stream> input, + StreamSink> output, { required FileSystem fileSystem, required Platform platform, this.ipv6 = false, @@ -30,7 +30,7 @@ class DapServer { this.enableAuthCodes = true, bool test = false, this.logger, - }) : channel = ByteStreamServerChannel(_input, _output, logger) { + }) : channel = ByteStreamServerChannel(input, output, logger) { adapter = test ? FlutterTestDebugAdapter(channel, fileSystem: fileSystem, diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart index 42a2e5427e..aeb3de5973 100644 --- a/packages/flutter_tools/lib/src/version.dart +++ b/packages/flutter_tools/lib/src/version.dart @@ -88,7 +88,7 @@ class FlutterVersion { String? _repositoryUrl; String? get repositoryUrl { - final String _ = channel; + final String _ = channel; // ignore: no_leading_underscores_for_local_identifiers return _repositoryUrl; } diff --git a/packages/flutter_tools/test/general.shard/ios/xcresult_test.dart b/packages/flutter_tools/test/general.shard/ios/xcresult_test.dart index 738c31467f..0d8d637645 100644 --- a/packages/flutter_tools/test/general.shard/ios/xcresult_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/xcresult_test.dart @@ -39,14 +39,14 @@ void main() { ); } - const FakeCommand _kWhichSysctlCommand = FakeCommand( + const FakeCommand kWhichSysctlCommand = FakeCommand( command: [ 'which', 'sysctl', ], ); - const FakeCommand _kx64CheckCommand = FakeCommand( + const FakeCommand kx64CheckCommand = FakeCommand( command: [ 'sysctl', 'hw.optional.arm64', @@ -61,8 +61,8 @@ void main() { }) { final FakeProcessManager fakeProcessManager = FakeProcessManager.list([ - _kWhichSysctlCommand, - _kx64CheckCommand, + kWhichSysctlCommand, + kx64CheckCommand, ]); final Xcode xcode = Xcode.test( processManager: fakeProcessManager, diff --git a/packages/flutter_tools/test/general.shard/utils_test.dart b/packages/flutter_tools/test/general.shard/utils_test.dart index 0b78963995..5e0f859e65 100644 --- a/packages/flutter_tools/test/general.shard/utils_test.dart +++ b/packages/flutter_tools/test/general.shard/utils_test.dart @@ -94,70 +94,70 @@ baz=qux }); group('text wrapping', () { - const int _lineLength = 40; - const String _longLine = 'This is a long line that needs to be wrapped.'; - final String _longLineWithNewlines = 'This is a long line with newlines that\n' + const int lineLength = 40; + const String longLine = 'This is a long line that needs to be wrapped.'; + final String longLineWithNewlines = 'This is a long line with newlines that\n' 'needs to be wrapped.\n\n' '${'0123456789' * 5}'; - final String _longAnsiLineWithNewlines = '${AnsiTerminal.red}This${AnsiTerminal.resetAll} is a long line with newlines that\n' + final String longAnsiLineWithNewlines = '${AnsiTerminal.red}This${AnsiTerminal.resetAll} is a long line with newlines that\n' 'needs to be wrapped.\n\n' '${AnsiTerminal.green}0123456789${AnsiTerminal.resetAll}' '${'0123456789' * 3}' '${AnsiTerminal.green}0123456789${AnsiTerminal.resetAll}'; - const String _onlyAnsiSequences = '${AnsiTerminal.red}${AnsiTerminal.resetAll}'; - final String _indentedLongLineWithNewlines = ' This is an indented long line with newlines that\n' + const String onlyAnsiSequences = '${AnsiTerminal.red}${AnsiTerminal.resetAll}'; + final String indentedLongLineWithNewlines = ' This is an indented long line with newlines that\n' 'needs to be wrapped.\n\tAnd preserves tabs.\n \n ' '${'0123456789' * 5}'; - const String _shortLine = 'Short line.'; - const String _indentedLongLine = ' This is an indented long line that needs to be ' + const String shortLine = 'Short line.'; + const String indentedLongLine = ' This is an indented long line that needs to be ' 'wrapped and indentation preserved.'; testWithoutContext('does not wrap by default in tests', () { - expect(wrapText(_longLine, columnWidth: 80, shouldWrap: true), equals(_longLine)); + expect(wrapText(longLine, columnWidth: 80, shouldWrap: true), equals(longLine)); }); testWithoutContext('can override wrap preference if preference is off', () { - expect(wrapText(_longLine, columnWidth: _lineLength, shouldWrap: true), equals(''' + expect(wrapText(longLine, columnWidth: lineLength, shouldWrap: true), equals(''' This is a long line that needs to be wrapped.''')); }); testWithoutContext('can override wrap preference if preference is on', () { - expect(wrapText(_longLine, shouldWrap: false, columnWidth: 80), equals(_longLine)); + expect(wrapText(longLine, shouldWrap: false, columnWidth: 80), equals(longLine)); }); testWithoutContext('does not wrap at all if not told to wrap', () { - expect(wrapText(_longLine, columnWidth: 80, shouldWrap: false), equals(_longLine)); + expect(wrapText(longLine, columnWidth: 80, shouldWrap: false), equals(longLine)); }); testWithoutContext('does not wrap short lines.', () { - expect(wrapText(_shortLine, columnWidth: _lineLength, shouldWrap: true), equals(_shortLine)); + expect(wrapText(shortLine, columnWidth: lineLength, shouldWrap: true), equals(shortLine)); }); testWithoutContext('able to wrap long lines', () { - expect(wrapText(_longLine, columnWidth: _lineLength, shouldWrap: true), equals(''' + expect(wrapText(longLine, columnWidth: lineLength, shouldWrap: true), equals(''' This is a long line that needs to be wrapped.''')); }); testWithoutContext('able to handle dynamically changing terminal column size', () { - expect(wrapText(_longLine, columnWidth: 20, shouldWrap: true), equals(''' + expect(wrapText(longLine, columnWidth: 20, shouldWrap: true), equals(''' This is a long line that needs to be wrapped.''')); - expect(wrapText(_longLine, columnWidth: _lineLength, shouldWrap: true), equals(''' + expect(wrapText(longLine, columnWidth: lineLength, shouldWrap: true), equals(''' This is a long line that needs to be wrapped.''')); }); testWithoutContext('wrap long lines with no whitespace', () { - expect(wrapText('0123456789' * 5, columnWidth: _lineLength, shouldWrap: true), equals(''' + expect(wrapText('0123456789' * 5, columnWidth: lineLength, shouldWrap: true), equals(''' 0123456789012345678901234567890123456789 0123456789''')); }); testWithoutContext('refuses to wrap to a column smaller than 10 characters', () { - expect(wrapText('$_longLine ${'0123456789' * 4}', columnWidth: 1, shouldWrap: true), equals(''' + expect(wrapText('$longLine ${'0123456789' * 4}', columnWidth: 1, shouldWrap: true), equals(''' This is a long line that needs @@ -169,21 +169,21 @@ wrapped. 0123456789''')); }); testWithoutContext('preserves indentation', () { - expect(wrapText(_indentedLongLine, columnWidth: _lineLength, shouldWrap: true), equals(''' + expect(wrapText(indentedLongLine, columnWidth: lineLength, shouldWrap: true), equals(''' This is an indented long line that needs to be wrapped and indentation preserved.''')); }); testWithoutContext('preserves indentation and stripping trailing whitespace', () { - expect(wrapText('$_indentedLongLine ', columnWidth: _lineLength, shouldWrap: true), equals(''' + expect(wrapText('$indentedLongLine ', columnWidth: lineLength, shouldWrap: true), equals(''' This is an indented long line that needs to be wrapped and indentation preserved.''')); }); testWithoutContext('wraps text with newlines', () { - expect(wrapText(_longLineWithNewlines, columnWidth: _lineLength, shouldWrap: true), equals(''' + expect(wrapText(longLineWithNewlines, columnWidth: lineLength, shouldWrap: true), equals(''' This is a long line with newlines that needs to be wrapped. @@ -192,7 +192,7 @@ needs to be wrapped. }); testWithoutContext('wraps text with ANSI sequences embedded', () { - expect(wrapText(_longAnsiLineWithNewlines, columnWidth: _lineLength, shouldWrap: true), equals(''' + expect(wrapText(longAnsiLineWithNewlines, columnWidth: lineLength, shouldWrap: true), equals(''' ${AnsiTerminal.red}This${AnsiTerminal.resetAll} is a long line with newlines that needs to be wrapped. @@ -201,12 +201,12 @@ ${AnsiTerminal.green}0123456789${AnsiTerminal.resetAll}''')); }); testWithoutContext('wraps text with only ANSI sequences', () { - expect(wrapText(_onlyAnsiSequences, columnWidth: _lineLength, shouldWrap: true), + expect(wrapText(onlyAnsiSequences, columnWidth: lineLength, shouldWrap: true), equals('${AnsiTerminal.red}${AnsiTerminal.resetAll}')); }); testWithoutContext('preserves indentation in the presence of newlines', () { - expect(wrapText(_indentedLongLineWithNewlines, columnWidth: _lineLength, shouldWrap: true), equals(''' + expect(wrapText(indentedLongLineWithNewlines, columnWidth: lineLength, shouldWrap: true), equals(''' This is an indented long line with newlines that needs to be wrapped. @@ -217,37 +217,37 @@ needs to be wrapped. }); testWithoutContext('removes trailing whitespace when wrapping', () { - expect(wrapText('$_longLine \t', columnWidth: _lineLength, shouldWrap: true), equals(''' + expect(wrapText('$longLine \t', columnWidth: lineLength, shouldWrap: true), equals(''' This is a long line that needs to be wrapped.''')); }); testWithoutContext('honors hangingIndent parameter', () { - expect(wrapText(_longLine, columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals(''' + expect(wrapText(longLine, columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals(''' This is a long line that needs to be wrapped.''')); }); testWithoutContext('handles hangingIndent with a single unwrapped line.', () { - expect(wrapText(_shortLine, columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals(''' + expect(wrapText(shortLine, columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals(''' Short line.''')); }); testWithoutContext('handles hangingIndent with two unwrapped lines and the second is empty.', () { - expect(wrapText('$_shortLine\n', columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals(''' + expect(wrapText('$shortLine\n', columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals(''' Short line. ''')); }); testWithoutContext('honors hangingIndent parameter on already indented line.', () { - expect(wrapText(_indentedLongLine, columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals(''' + expect(wrapText(indentedLongLine, columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals(''' This is an indented long line that needs to be wrapped and indentation preserved.''')); }); testWithoutContext('honors hangingIndent and indent parameters at the same time.', () { - expect(wrapText(_indentedLongLine, columnWidth: _lineLength, indent: 6, hangingIndent: 6, shouldWrap: true), equals(''' + expect(wrapText(indentedLongLine, columnWidth: lineLength, indent: 6, hangingIndent: 6, shouldWrap: true), equals(''' This is an indented long line that needs to be wrapped and indentation @@ -255,14 +255,14 @@ Short line. }); testWithoutContext('honors indent parameter on already indented line.', () { - expect(wrapText(_indentedLongLine, columnWidth: _lineLength, indent: 6, shouldWrap: true), equals(''' + expect(wrapText(indentedLongLine, columnWidth: lineLength, indent: 6, shouldWrap: true), equals(''' This is an indented long line that needs to be wrapped and indentation preserved.''')); }); testWithoutContext('honors hangingIndent parameter on already indented line.', () { - expect(wrapText(_indentedLongLineWithNewlines, columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals(''' + expect(wrapText(indentedLongLineWithNewlines, columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals(''' This is an indented long line with newlines that needs to be wrapped. diff --git a/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart b/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart index f6bb0acf17..7879d1ef71 100644 --- a/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart +++ b/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart @@ -30,8 +30,8 @@ void main() { }); testWithoutContext('device.getDevices', () async { - final BasicProject _project = BasicProject(); - await _project.setUpIn(tempDir); + final BasicProject project = BasicProject(); + await project.setUpIn(tempDir); final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); diff --git a/packages/flutter_tools/test/integration.shard/debug_adapter/flutter_adapter_test.dart b/packages/flutter_tools/test/integration.shard/debug_adapter/flutter_adapter_test.dart index 5de689234c..8173713f3b 100644 --- a/packages/flutter_tools/test/integration.shard/debug_adapter/flutter_adapter_test.dart +++ b/packages/flutter_tools/test/integration.shard/debug_adapter/flutter_adapter_test.dart @@ -37,8 +37,8 @@ void main() { }); testWithoutContext('can run and terminate a Flutter app in debug mode', () async { - final BasicProject _project = BasicProject(); - await _project.setUpIn(tempDir); + final BasicProject project = BasicProject(); + await project.setUpIn(tempDir); // Once the "topLevelFunction" output arrives, we can terminate the app. unawaited( @@ -50,7 +50,7 @@ void main() { final List outputEvents = await dap.client.collectAllOutput( launch: () => dap.client .launch( - cwd: _project.dir.path, + cwd: project.dir.path, toolArgs: ['-d', 'flutter-tester'], ), ); @@ -67,8 +67,8 @@ void main() { }); testWithoutContext('can run and terminate a Flutter app in noDebug mode', () async { - final BasicProject _project = BasicProject(); - await _project.setUpIn(tempDir); + final BasicProject project = BasicProject(); + await project.setUpIn(tempDir); // Once the "topLevelFunction" output arrives, we can terminate the app. unawaited( @@ -80,7 +80,7 @@ void main() { final List outputEvents = await dap.client.collectAllOutput( launch: () => dap.client .launch( - cwd: _project.dir.path, + cwd: project.dir.path, noDebug: true, toolArgs: ['-d', 'flutter-tester'], ), @@ -97,13 +97,13 @@ void main() { }); testWithoutContext('correctly outputs launch errors and terminates', () async { - final CompileErrorProject _project = CompileErrorProject(); - await _project.setUpIn(tempDir); + final CompileErrorProject project = CompileErrorProject(); + await project.setUpIn(tempDir); final List outputEvents = await dap.client.collectAllOutput( launch: () => dap.client .launch( - cwd: _project.dir.path, + cwd: project.dir.path, toolArgs: ['-d', 'flutter-tester'], ), ); @@ -115,15 +115,15 @@ void main() { }); testWithoutContext('can hot reload', () async { - final BasicProject _project = BasicProject(); - await _project.setUpIn(tempDir); + final BasicProject project = BasicProject(); + await project.setUpIn(tempDir); // Launch the app and wait for it to print "topLevelFunction". await Future.wait(>[ dap.client.outputEvents.firstWhere((OutputEventBody output) => output.output.startsWith('topLevelFunction')), dap.client.start( launch: () => dap.client.launch( - cwd: _project.dir.path, + cwd: project.dir.path, noDebug: true, toolArgs: ['-d', 'flutter-tester'], ), @@ -152,15 +152,15 @@ void main() { }); testWithoutContext('can hot restart', () async { - final BasicProject _project = BasicProject(); - await _project.setUpIn(tempDir); + final BasicProject project = BasicProject(); + await project.setUpIn(tempDir); // Launch the app and wait for it to print "topLevelFunction". await Future.wait(>[ dap.client.outputEvents.firstWhere((OutputEventBody output) => output.output.startsWith('topLevelFunction')), dap.client.start( launch: () => dap.client.launch( - cwd: _project.dir.path, + cwd: project.dir.path, noDebug: true, toolArgs: ['-d', 'flutter-tester'], ), @@ -189,8 +189,8 @@ void main() { }); testWithoutContext('can hot restart when exceptions occur on outgoing isolates', () async { - final BasicProjectThatThrows _project = BasicProjectThatThrows(); - await _project.setUpIn(tempDir); + final BasicProjectThatThrows project = BasicProjectThatThrows(); + await project.setUpIn(tempDir); // Launch the app and wait for it to stop at an exception. int originalThreadId, newThreadId; @@ -200,7 +200,7 @@ void main() { dap.client.start( exceptionPauseMode: 'All', // Ensure we stop on all exceptions launch: () => dap.client.launch( - cwd: _project.dir.path, + cwd: project.dir.path, toolArgs: ['-d', 'flutter-tester'], ), ), @@ -222,8 +222,8 @@ void main() { }); testWithoutContext('sends events for extension state updates', () async { - final BasicProject _project = BasicProject(); - await _project.setUpIn(tempDir); + final BasicProject project = BasicProject(); + await project.setUpIn(tempDir); const String debugPaintRpc = 'ext.flutter.debugPaint'; // Create a future to capture the isolate ID when the debug paint service @@ -239,7 +239,7 @@ void main() { output.output.startsWith('topLevelFunction')), dap.client.start( launch: () => dap.client.launch( - cwd: _project.dir.path, + cwd: project.dir.path, toolArgs: ['-d', 'flutter-tester'], ), ), diff --git a/packages/flutter_tools/test/integration.shard/debug_adapter/test_server.dart b/packages/flutter_tools/test/integration.shard/debug_adapter/test_server.dart index 03bf6dd83b..70b448dffb 100644 --- a/packages/flutter_tools/test/integration.shard/debug_adapter/test_server.dart +++ b/packages/flutter_tools/test/integration.shard/debug_adapter/test_server.dart @@ -131,8 +131,8 @@ class OutOfProcessDapTestServer extends DapTestServer { ...?additionalArgs, ]; - final Process _process = await Process.start(executable, args); + final Process process = await Process.start(executable, args); - return OutOfProcessDapTestServer._(_process, logger); + return OutOfProcessDapTestServer._(process, logger); } } diff --git a/packages/flutter_tools/test/integration.shard/debugger_stepping_test.dart b/packages/flutter_tools/test/integration.shard/debugger_stepping_test.dart index 2b259c2b70..652ca84875 100644 --- a/packages/flutter_tools/test/integration.shard/debugger_stepping_test.dart +++ b/packages/flutter_tools/test/integration.shard/debugger_stepping_test.dart @@ -21,32 +21,32 @@ void main() { }); testWithoutContext('can step over statements', () async { - final SteppingProject _project = SteppingProject(); - await _project.setUpIn(tempDir); + final SteppingProject project = SteppingProject(); + await project.setUpIn(tempDir); - final FlutterRunTestDriver _flutter = FlutterRunTestDriver(tempDir); + final FlutterRunTestDriver flutter = FlutterRunTestDriver(tempDir); - await _flutter.run(withDebugger: true, startPaused: true); - await _flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine); - await _flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint. + await flutter.run(withDebugger: true, startPaused: true); + await flutter.addBreakpoint(project.breakpointUri, project.breakpointLine); + await flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint. - expect((await _flutter.getSourceLocation())?.line, equals(_project.breakpointLine)); + expect((await flutter.getSourceLocation())?.line, equals(project.breakpointLine)); // Issue 5 steps, ensuring that we end up on the annotated lines each time. - for (int i = 1; i <= _project.numberOfSteps; i += 1) { - await _flutter.stepOverOrOverAsyncSuspension(); - final SourcePosition? location = await _flutter.getSourceLocation(); + for (int i = 1; i <= project.numberOfSteps; i += 1) { + await flutter.stepOverOrOverAsyncSuspension(); + final SourcePosition? location = await flutter.getSourceLocation(); final int? actualLine = location?.line; // Get the line we're expected to stop at by searching for the comment // within the source code. - final int expectedLine = _project.lineForStep(i); + final int expectedLine = project.lineForStep(i); expect(actualLine, equals(expectedLine), reason: 'After $i steps, debugger should stop at $expectedLine but stopped at $actualLine' ); } - await _flutter.stop(); + await flutter.stop(); }); } diff --git a/packages/flutter_tools/test/integration.shard/deferred_components_test.dart b/packages/flutter_tools/test/integration.shard/deferred_components_test.dart index 33fb485a13..359059ba9d 100644 --- a/packages/flutter_tools/test/integration.shard/deferred_components_test.dart +++ b/packages/flutter_tools/test/integration.shard/deferred_components_test.dart @@ -14,15 +14,15 @@ import 'test_utils.dart'; void main() { late Directory tempDir; - late FlutterRunTestDriver _flutter; + late FlutterRunTestDriver flutter; setUp(() async { tempDir = createResolvedTempDirectorySync('run_test.'); - _flutter = FlutterRunTestDriver(tempDir); + flutter = FlutterRunTestDriver(tempDir); }); tearDown(() async { - await _flutter.stop(); + await flutter.stop(); tryToDelete(tempDir); }); diff --git a/packages/flutter_tools/test/integration.shard/expression_evaluation_test.dart b/packages/flutter_tools/test/integration.shard/expression_evaluation_test.dart index 52118fae7e..1b72e69422 100644 --- a/packages/flutter_tools/test/integration.shard/expression_evaluation_test.dart +++ b/packages/flutter_tools/test/integration.shard/expression_evaluation_test.dart @@ -15,130 +15,130 @@ import 'test_driver.dart'; import 'test_utils.dart'; void batch1() { - final BasicProject _project = BasicProject(); + final BasicProject project = BasicProject(); Directory tempDir; - FlutterRunTestDriver _flutter; + FlutterRunTestDriver flutter; Future initProject() async { tempDir = createResolvedTempDirectorySync('run_expression_eval_test.'); - await _project.setUpIn(tempDir); - _flutter = FlutterRunTestDriver(tempDir); + await project.setUpIn(tempDir); + flutter = FlutterRunTestDriver(tempDir); } Future cleanProject() async { - await _flutter.stop(); + await flutter.stop(); tryToDelete(tempDir); } Future breakInBuildMethod(FlutterTestDriver flutter) async { - await _flutter.breakAt( - _project.buildMethodBreakpointUri, - _project.buildMethodBreakpointLine, + await flutter.breakAt( + project.buildMethodBreakpointUri, + project.buildMethodBreakpointLine, ); } Future breakInTopLevelFunction(FlutterTestDriver flutter) async { - await _flutter.breakAt( - _project.topLevelFunctionBreakpointUri, - _project.topLevelFunctionBreakpointLine, + await flutter.breakAt( + project.topLevelFunctionBreakpointUri, + project.topLevelFunctionBreakpointLine, ); } testWithoutContext('flutter run expression evaluation - can evaluate trivial expressions in top level function', () async { await initProject(); - await _flutter.run(withDebugger: true); - await breakInTopLevelFunction(_flutter); - await evaluateTrivialExpressions(_flutter); + await flutter.run(withDebugger: true); + await breakInTopLevelFunction(flutter); + await evaluateTrivialExpressions(flutter); await cleanProject(); }); testWithoutContext('flutter run expression evaluation - can evaluate trivial expressions in build method', () async { await initProject(); - await _flutter.run(withDebugger: true); - await breakInBuildMethod(_flutter); - await evaluateTrivialExpressions(_flutter); + await flutter.run(withDebugger: true); + await breakInBuildMethod(flutter); + await evaluateTrivialExpressions(flutter); await cleanProject(); }); testWithoutContext('flutter run expression evaluation - can evaluate complex expressions in top level function', () async { await initProject(); - await _flutter.run(withDebugger: true); - await breakInTopLevelFunction(_flutter); - await evaluateComplexExpressions(_flutter); + await flutter.run(withDebugger: true); + await breakInTopLevelFunction(flutter); + await evaluateComplexExpressions(flutter); await cleanProject(); }); testWithoutContext('flutter run expression evaluation - can evaluate complex expressions in build method', () async { await initProject(); - await _flutter.run(withDebugger: true); - await breakInBuildMethod(_flutter); - await evaluateComplexExpressions(_flutter); + await flutter.run(withDebugger: true); + await breakInBuildMethod(flutter); + await evaluateComplexExpressions(flutter); await cleanProject(); }); testWithoutContext('flutter run expression evaluation - can evaluate expressions returning complex objects in top level function', () async { await initProject(); - await _flutter.run(withDebugger: true); - await breakInTopLevelFunction(_flutter); - await evaluateComplexReturningExpressions(_flutter); + await flutter.run(withDebugger: true); + await breakInTopLevelFunction(flutter); + await evaluateComplexReturningExpressions(flutter); await cleanProject(); }); testWithoutContext('flutter run expression evaluation - can evaluate expressions returning complex objects in build method', () async { await initProject(); - await _flutter.run(withDebugger: true); - await breakInBuildMethod(_flutter); - await evaluateComplexReturningExpressions(_flutter); + await flutter.run(withDebugger: true); + await breakInBuildMethod(flutter); + await evaluateComplexReturningExpressions(flutter); await cleanProject(); }); } void batch2() { - final TestsProject _project = TestsProject(); + final TestsProject project = TestsProject(); Directory tempDir; - FlutterTestTestDriver _flutter; + FlutterTestTestDriver flutter; Future initProject() async { tempDir = createResolvedTempDirectorySync('test_expression_eval_test.'); - await _project.setUpIn(tempDir); - _flutter = FlutterTestTestDriver(tempDir); + await project.setUpIn(tempDir); + flutter = FlutterTestTestDriver(tempDir); } Future cleanProject() async { - await _flutter?.waitForCompletion(); + await flutter?.waitForCompletion(); tryToDelete(tempDir); } testWithoutContext('flutter test expression evaluation - can evaluate trivial expressions in a test', () async { await initProject(); - await _flutter.test( + await flutter.test( withDebugger: true, - beforeStart: () => _flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine), + beforeStart: () => flutter.addBreakpoint(project.breakpointUri, project.breakpointLine), ); - await _flutter.waitForPause(); - await evaluateTrivialExpressions(_flutter); + await flutter.waitForPause(); + await evaluateTrivialExpressions(flutter); await cleanProject(); }); testWithoutContext('flutter test expression evaluation - can evaluate complex expressions in a test', () async { await initProject(); - await _flutter.test( + await flutter.test( withDebugger: true, - beforeStart: () => _flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine), + beforeStart: () => flutter.addBreakpoint(project.breakpointUri, project.breakpointLine), ); - await _flutter.waitForPause(); - await evaluateComplexExpressions(_flutter); + await flutter.waitForPause(); + await evaluateComplexExpressions(flutter); await cleanProject(); }); testWithoutContext('flutter test expression evaluation - can evaluate expressions returning complex objects in a test', () async { await initProject(); - await _flutter.test( + await flutter.test( withDebugger: true, - beforeStart: () => _flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine), + beforeStart: () => flutter.addBreakpoint(project.breakpointUri, project.breakpointLine), ); - await _flutter.waitForPause(); - await evaluateComplexReturningExpressions(_flutter); + await flutter.waitForPause(); + await evaluateComplexReturningExpressions(flutter); await cleanProject(); }); } diff --git a/packages/flutter_tools/test/integration.shard/flutter_attach_test.dart b/packages/flutter_tools/test/integration.shard/flutter_attach_test.dart index af48dc7d7d..9dda4777e4 100644 --- a/packages/flutter_tools/test/integration.shard/flutter_attach_test.dart +++ b/packages/flutter_tools/test/integration.shard/flutter_attach_test.dart @@ -13,15 +13,15 @@ import 'test_driver.dart'; import 'test_utils.dart'; void main() { - FlutterRunTestDriver _flutterRun, _flutterAttach; - final BasicProject _project = BasicProject(); + FlutterRunTestDriver flutterRun, flutterAttach; + final BasicProject project = BasicProject(); Directory tempDir; setUp(() async { tempDir = createResolvedTempDirectorySync('attach_test.'); - await _project.setUpIn(tempDir); - _flutterRun = FlutterRunTestDriver(tempDir, logPrefix: ' RUN '); - _flutterAttach = FlutterRunTestDriver( + await project.setUpIn(tempDir); + flutterRun = FlutterRunTestDriver(tempDir, logPrefix: ' RUN '); + flutterAttach = FlutterRunTestDriver( tempDir, logPrefix: 'ATTACH ', // Only one DDS instance can be connected to the VM service at a time. @@ -32,74 +32,74 @@ void main() { }); tearDown(() async { - await _flutterAttach.detach(); - await _flutterRun.stop(); + await flutterAttach.detach(); + await flutterRun.stop(); tryToDelete(tempDir); }); testWithoutContext('can hot reload', () async { - await _flutterRun.run(withDebugger: true); - await _flutterAttach.attach(_flutterRun.vmServicePort); - await _flutterAttach.hotReload(); + await flutterRun.run(withDebugger: true); + await flutterAttach.attach(flutterRun.vmServicePort); + await flutterAttach.hotReload(); }); testWithoutContext('can detach, reattach, hot reload', () async { - await _flutterRun.run(withDebugger: true); - await _flutterAttach.attach(_flutterRun.vmServicePort); - await _flutterAttach.detach(); - await _flutterAttach.attach(_flutterRun.vmServicePort); - await _flutterAttach.hotReload(); + await flutterRun.run(withDebugger: true); + await flutterAttach.attach(flutterRun.vmServicePort); + await flutterAttach.detach(); + await flutterAttach.attach(flutterRun.vmServicePort); + await flutterAttach.hotReload(); }); testWithoutContext('killing process behaves the same as detach ', () async { - await _flutterRun.run(withDebugger: true); - await _flutterAttach.attach(_flutterRun.vmServicePort); - await _flutterAttach.quit(); - _flutterAttach = FlutterRunTestDriver( + await flutterRun.run(withDebugger: true); + await flutterAttach.attach(flutterRun.vmServicePort); + await flutterAttach.quit(); + flutterAttach = FlutterRunTestDriver( tempDir, logPrefix: 'ATTACH-2', spawnDdsInstance: false, ); - await _flutterAttach.attach(_flutterRun.vmServicePort); - await _flutterAttach.hotReload(); + await flutterAttach.attach(flutterRun.vmServicePort); + await flutterAttach.hotReload(); }); testWithoutContext('sets activeDevToolsServerAddress extension', () async { - await _flutterRun.run( + await flutterRun.run( startPaused: true, withDebugger: true, additionalCommandArgs: ['--devtools-server-address', 'http://127.0.0.1:9105'], ); - await _flutterRun.resume(); + await flutterRun.resume(); await pollForServiceExtensionValue( - testDriver: _flutterRun, + testDriver: flutterRun, extension: 'ext.flutter.activeDevToolsServerAddress', continuePollingValue: '', matches: equals('http://127.0.0.1:9105'), ); await pollForServiceExtensionValue( - testDriver: _flutterRun, + testDriver: flutterRun, extension: 'ext.flutter.connectedVmServiceUri', continuePollingValue: '', matches: isNotEmpty, ); - final Response response = await _flutterRun.callServiceExtension('ext.flutter.connectedVmServiceUri'); + final Response response = await flutterRun.callServiceExtension('ext.flutter.connectedVmServiceUri'); final String vmServiceUri = response.json['value'] as String; // Attach with a different DevTools server address. - await _flutterAttach.attach( - _flutterRun.vmServicePort, + await flutterAttach.attach( + flutterRun.vmServicePort, additionalCommandArgs: ['--devtools-server-address', 'http://127.0.0.1:9110'], ); await pollForServiceExtensionValue( - testDriver: _flutterAttach, + testDriver: flutterAttach, extension: 'ext.flutter.activeDevToolsServerAddress', continuePollingValue: '', matches: equals('http://127.0.0.1:9110'), ); await pollForServiceExtensionValue( - testDriver: _flutterRun, + testDriver: flutterRun, extension: 'ext.flutter.connectedVmServiceUri', continuePollingValue: '', matches: equals(vmServiceUri), diff --git a/packages/flutter_tools/test/integration.shard/flutter_run_test.dart b/packages/flutter_tools/test/integration.shard/flutter_run_test.dart index 0b3c65a75a..3beeef3b56 100644 --- a/packages/flutter_tools/test/integration.shard/flutter_run_test.dart +++ b/packages/flutter_tools/test/integration.shard/flutter_run_test.dart @@ -15,17 +15,17 @@ import 'test_utils.dart'; void main() { Directory tempDir; - final BasicProject _project = BasicProject(); - FlutterRunTestDriver _flutter; + final BasicProject project = BasicProject(); + FlutterRunTestDriver flutter; setUp(() async { tempDir = createResolvedTempDirectorySync('run_test.'); - await _project.setUpIn(tempDir); - _flutter = FlutterRunTestDriver(tempDir); + await project.setUpIn(tempDir); + flutter = FlutterRunTestDriver(tempDir); }); tearDown(() async { - await _flutter.stop(); + await flutter.stop(); tryToDelete(tempDir); }); @@ -36,35 +36,35 @@ void main() { // some of the checks for devices. final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); - const ProcessManager _processManager = LocalProcessManager(); - final ProcessResult _proc = await _processManager.run( + const ProcessManager processManager = LocalProcessManager(); + final ProcessResult proc = await processManager.run( [flutterBin, 'run', '-d', 'invalid-device-id'], workingDirectory: tempDir.path, ); - expect(_proc.stdout, isNot(contains('flutter has exited unexpectedly'))); - expect(_proc.stderr, isNot(contains('flutter has exited unexpectedly'))); - if (!_proc.stderr.toString().contains('Unable to locate a development') - && !_proc.stdout.toString().contains('No devices found with name or id matching')) { + expect(proc.stdout, isNot(contains('flutter has exited unexpectedly'))); + expect(proc.stderr, isNot(contains('flutter has exited unexpectedly'))); + if (!proc.stderr.toString().contains('Unable to locate a development') + && !proc.stdout.toString().contains('No devices found with name or id matching')) { fail("'flutter run -d invalid-device-id' did not produce the expected error"); } }); testWithoutContext('sets activeDevToolsServerAddress extension', () async { - await _flutter.run( + await flutter.run( startPaused: true, withDebugger: true, additionalCommandArgs: ['--devtools-server-address', 'http://127.0.0.1:9110'], ); - await _flutter.resume(); + await flutter.resume(); await pollForServiceExtensionValue( - testDriver: _flutter, + testDriver: flutter, extension: 'ext.flutter.activeDevToolsServerAddress', continuePollingValue: '', matches: equals('http://127.0.0.1:9110'), ); await pollForServiceExtensionValue( - testDriver: _flutter, + testDriver: flutter, extension: 'ext.flutter.connectedVmServiceUri', continuePollingValue: '', matches: isNotEmpty, diff --git a/packages/flutter_tools/test/integration.shard/flutter_run_with_error_test.dart b/packages/flutter_tools/test/integration.shard/flutter_run_with_error_test.dart index fcfd61b373..840f0a6c0b 100644 --- a/packages/flutter_tools/test/integration.shard/flutter_run_with_error_test.dart +++ b/packages/flutter_tools/test/integration.shard/flutter_run_with_error_test.dart @@ -18,14 +18,14 @@ import 'test_utils.dart'; void main() { Directory tempDir; - final ProjectWithEarlyError _project = ProjectWithEarlyError(); - const String _exceptionStart = '══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞══════════════════'; - FlutterRunTestDriver _flutter; + final ProjectWithEarlyError project = ProjectWithEarlyError(); + const String exceptionStart = '══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞══════════════════'; + FlutterRunTestDriver flutter; setUp(() async { tempDir = createResolvedTempDirectorySync('run_test.'); - await _project.setUpIn(tempDir); - _flutter = FlutterRunTestDriver(tempDir); + await project.setUpIn(tempDir); + flutter = FlutterRunTestDriver(tempDir); }); tearDown(() async { @@ -75,23 +75,23 @@ void main() { await process.exitCode; - expect(stdout.toString(), contains(_exceptionStart)); + expect(stdout.toString(), contains(exceptionStart)); }); testWithoutContext('flutter run in machine mode does not print an error', () async { final StringBuffer stdout = StringBuffer(); - await _flutter.run( + await flutter.run( startPaused: true, withDebugger: true, structuredErrors: true, ); - await _flutter.resume(); + await flutter.resume(); final Completer completer = Completer(); await Future(() async { - _flutter.stdout.listen((String line) { + flutter.stdout.listen((String line) { stdout.writeln(line); }); await completer.future; @@ -99,8 +99,8 @@ void main() { // We don't expect to see any output but want to write to stdout anyway. completer.complete(); }); - await _flutter.stop(); + await flutter.stop(); - expect(stdout.toString(), isNot(contains(_exceptionStart))); + expect(stdout.toString(), isNot(contains(exceptionStart))); }); } diff --git a/packages/flutter_tools/test/integration.shard/lifetime_test.dart b/packages/flutter_tools/test/integration.shard/lifetime_test.dart index 2a4abf455b..2be89363a7 100644 --- a/packages/flutter_tools/test/integration.shard/lifetime_test.dart +++ b/packages/flutter_tools/test/integration.shard/lifetime_test.dart @@ -17,30 +17,30 @@ import 'test_utils.dart'; const Duration requiredLifespan = Duration(seconds: 5); void main() { - final BasicProject _project = BasicProject(); - FlutterRunTestDriver _flutter; + final BasicProject project = BasicProject(); + FlutterRunTestDriver flutter; Directory tempDir; setUp(() async { tempDir = createResolvedTempDirectorySync('lifetime_test.'); - await _project.setUpIn(tempDir); - _flutter = FlutterRunTestDriver(tempDir); + await project.setUpIn(tempDir); + flutter = FlutterRunTestDriver(tempDir); }); tearDown(() async { - await _flutter.stop(); + await flutter.stop(); tryToDelete(tempDir); }); testWithoutContext('flutter run does not terminate when a debugger is attached', () async { - await _flutter.run(withDebugger: true); + await flutter.run(withDebugger: true); await Future.delayed(requiredLifespan); - expect(_flutter.hasExited, equals(false)); + expect(flutter.hasExited, equals(false)); }); testWithoutContext('flutter run does not terminate when a debugger is attached and pause-on-exceptions', () async { - await _flutter.run(withDebugger: true, pauseOnExceptions: true); + await flutter.run(withDebugger: true, pauseOnExceptions: true); await Future.delayed(requiredLifespan); - expect(_flutter.hasExited, equals(false)); + expect(flutter.hasExited, equals(false)); }); } diff --git a/packages/flutter_tools/test/integration.shard/multidex_build_test.dart b/packages/flutter_tools/test/integration.shard/multidex_build_test.dart index 21c43e1c00..8a194edc35 100644 --- a/packages/flutter_tools/test/integration.shard/multidex_build_test.dart +++ b/packages/flutter_tools/test/integration.shard/multidex_build_test.dart @@ -14,15 +14,15 @@ import 'test_utils.dart'; void main() { Directory tempDir; - FlutterRunTestDriver _flutter; + FlutterRunTestDriver flutter; setUp(() async { tempDir = createResolvedTempDirectorySync('run_test.'); - _flutter = FlutterRunTestDriver(tempDir); + flutter = FlutterRunTestDriver(tempDir); }); tearDown(() async { - await _flutter.stop(); + await flutter.stop(); tryToDelete(tempDir); }); diff --git a/packages/flutter_tools/test/integration.shard/observatory_port_test.dart b/packages/flutter_tools/test/integration.shard/observatory_port_test.dart index 0912deb59d..b47a62c1d5 100644 --- a/packages/flutter_tools/test/integration.shard/observatory_port_test.dart +++ b/packages/flutter_tools/test/integration.shard/observatory_port_test.dart @@ -44,11 +44,11 @@ Future waitForObservatoryMessage(Process process, int port) async { void main() { Directory tempDir; - final BasicProject _project = BasicProject(); + final BasicProject project = BasicProject(); setUp(() async { tempDir = createResolvedTempDirectorySync('run_test.'); - await _project.setUpIn(tempDir); + await project.setUpIn(tempDir); }); tearDown(() async { diff --git a/packages/flutter_tools/test/integration.shard/stateless_stateful_hot_reload_test.dart b/packages/flutter_tools/test/integration.shard/stateless_stateful_hot_reload_test.dart index 2b21048c27..8a1068c9f7 100644 --- a/packages/flutter_tools/test/integration.shard/stateless_stateful_hot_reload_test.dart +++ b/packages/flutter_tools/test/integration.shard/stateless_stateful_hot_reload_test.dart @@ -17,33 +17,33 @@ import 'test_utils.dart'; // stateful one and back. void main() { Directory tempDir; - final HotReloadProject _project = HotReloadProject(); - FlutterRunTestDriver _flutter; + final HotReloadProject project = HotReloadProject(); + FlutterRunTestDriver flutter; setUp(() async { tempDir = createResolvedTempDirectorySync('hot_reload_test.'); - await _project.setUpIn(tempDir); - _flutter = FlutterRunTestDriver(tempDir); + await project.setUpIn(tempDir); + flutter = FlutterRunTestDriver(tempDir); }); tearDown(() async { - await _flutter?.stop(); + await flutter?.stop(); tryToDelete(tempDir); }); testWithoutContext('Can switch between stateless and stateful', () async { - await _flutter.run(); - await _flutter.hotReload(); + await flutter.run(); + await flutter.hotReload(); final StringBuffer stdout = StringBuffer(); - final StreamSubscription subscription = _flutter.stdout.listen(stdout.writeln); + final StreamSubscription subscription = flutter.stdout.listen(stdout.writeln); // switch to stateful. - _project.toggleState(); - await _flutter.hotReload(); + project.toggleState(); + await flutter.hotReload(); // switch to stateless. - _project.toggleState(); - await _flutter.hotReload(); + project.toggleState(); + await flutter.hotReload(); final String logs = stdout.toString(); diff --git a/packages/flutter_tools/test/integration.shard/test_driver.dart b/packages/flutter_tools/test/integration.shard/test_driver.dart index 190a64a8e1..d5d524413a 100644 --- a/packages/flutter_tools/test/integration.shard/test_driver.dart +++ b/packages/flutter_tools/test/integration.shard/test_driver.dart @@ -103,8 +103,8 @@ abstract class FlutterTestDriver { } _debugPrint('Spawning flutter $arguments in ${_projectFolder.path}'); - const ProcessManager _processManager = LocalProcessManager(); - _process = await _processManager.start( + const ProcessManager processManager = LocalProcessManager(); + _process = await processManager.start( [flutterBin] .followedBy(arguments) .toList(), @@ -760,8 +760,8 @@ class FlutterRunTestDriver extends FlutterTestDriver { } class FlutterTestTestDriver extends FlutterTestDriver { - FlutterTestTestDriver(Directory _projectFolder, {String? logPrefix}) - : super(_projectFolder, logPrefix: logPrefix); + FlutterTestTestDriver(Directory projectFolder, {String? logPrefix}) + : super(projectFolder, logPrefix: logPrefix); Future test({ String testFile = 'test/test.dart', diff --git a/packages/flutter_tools/test/integration.shard/vmservice_integration_test.dart b/packages/flutter_tools/test/integration.shard/vmservice_integration_test.dart index 871587f725..c03a403bd7 100644 --- a/packages/flutter_tools/test/integration.shard/vmservice_integration_test.dart +++ b/packages/flutter_tools/test/integration.shard/vmservice_integration_test.dart @@ -21,8 +21,8 @@ void main() { setUp(() async { tempDir = createResolvedTempDirectorySync('vmservice_integration_test.'); - final BasicProject _project = BasicProject(); - await _project.setUpIn(tempDir); + final BasicProject project = BasicProject(); + await project.setUpIn(tempDir); flutter = FlutterRunTestDriver(tempDir); await flutter.run(withDebugger: true); diff --git a/packages/flutter_tools/test/web.shard/debugger_stepping_web_test.dart b/packages/flutter_tools/test/web.shard/debugger_stepping_web_test.dart index ce0f07d4f2..c2656ad538 100644 --- a/packages/flutter_tools/test/web.shard/debugger_stepping_web_test.dart +++ b/packages/flutter_tools/test/web.shard/debugger_stepping_web_test.dart @@ -20,27 +20,27 @@ void main() { }); testWithoutContext('Web debugger can step over statements', () async { - final WebSteppingProject _project = WebSteppingProject(); - await _project.setUpIn(tempDirectory); + final WebSteppingProject project = WebSteppingProject(); + await project.setUpIn(tempDirectory); flutter = FlutterRunTestDriver(tempDirectory); await flutter.run( withDebugger: true, startPaused: true, chrome: true, additionalCommandArgs: ['--verbose', '--web-renderer=html']); - await flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine); + await flutter.addBreakpoint(project.breakpointUri, project.breakpointLine); await flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint. - expect((await flutter.getSourceLocation()).line, equals(_project.breakpointLine)); + expect((await flutter.getSourceLocation()).line, equals(project.breakpointLine)); // Issue 5 steps, ensuring that we end up on the annotated lines each time. - for (int i = 1; i <= _project.numberOfSteps; i += 1) { + for (int i = 1; i <= project.numberOfSteps; i += 1) { await flutter.stepOverOrOverAsyncSuspension(); final SourcePosition location = await flutter.getSourceLocation(); final int actualLine = location.line; // Get the line we're expected to stop at by searching for the comment // within the source code. - final int expectedLine = _project.lineForStep(i); + final int expectedLine = project.lineForStep(i); expect(actualLine, equals(expectedLine), reason: 'After $i steps, debugger should stop at $expectedLine but stopped at $actualLine' diff --git a/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart b/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart index dbcdd34d67..39dac10822 100644 --- a/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart +++ b/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart @@ -152,11 +152,11 @@ class PathUrlStrategy extends HashUrlStrategy { /// The [PlatformLocation] parameter is useful for testing to mock out browser /// interactions. PathUrlStrategy([ - PlatformLocation _platformLocation = const BrowserPlatformLocation(), + PlatformLocation platformLocation = const BrowserPlatformLocation(), ]) : _basePath = stripTrailingSlash(extractPathname(checkBaseHref( - _platformLocation.getBaseHref(), + platformLocation.getBaseHref(), ))), - super(_platformLocation); + super(platformLocation); final String _basePath; diff --git a/packages/flutter_web_plugins/lib/src/navigation_non_web/url_strategy.dart b/packages/flutter_web_plugins/lib/src/navigation_non_web/url_strategy.dart index 76b31baf68..b4e7cb1c46 100644 --- a/packages/flutter_web_plugins/lib/src/navigation_non_web/url_strategy.dart +++ b/packages/flutter_web_plugins/lib/src/navigation_non_web/url_strategy.dart @@ -92,8 +92,8 @@ class PathUrlStrategy extends HashUrlStrategy { /// /// The [PlatformLocation] parameter is useful for testing to mock out browser /// interations. - PathUrlStrategy([PlatformLocation? _platformLocation]) - : super(_platformLocation); + PathUrlStrategy([PlatformLocation? platformLocation]) + : super(platformLocation); @override String getPath() => '';