From 8560d914eb8bc965306dfb9336425cac19670358 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Tue, 22 Mar 2022 11:00:23 -0700 Subject: [PATCH] Upgrade to flutter_lints 2.0 (#99881) --- dev/bots/analyze_sample_code.dart | 3 +- .../flutter/lib/src/animation/animation.dart | 4 +-- .../flutter/lib/src/cupertino/colors.dart | 2 +- .../lib/src/cupertino/context_menu.dart | 8 ++--- .../flutter/lib/src/cupertino/form_row.dart | 6 ++-- .../flutter/lib/src/rendering/proxy_box.dart | 2 +- .../flutter/lib/src/widgets/container.dart | 2 +- .../lib/src/widgets/implicit_animations.dart | 6 ++-- packages/flutter/lib/src/widgets/routes.dart | 2 +- .../flutter/lib/src/widgets/scroll_view.dart | 24 ++++++------- .../flutter/lib/src/widgets/scrollbar.dart | 36 +++++++++---------- .../lib/src/flutter_plugins.dart | 1 + .../templates/app/pubspec.yaml.tmpl | 2 +- .../templates/module/common/pubspec.yaml.tmpl | 2 +- .../templates/package/pubspec.yaml.tmpl | 2 +- .../templates/plugin_shared/pubspec.yaml.tmpl | 2 +- .../templates/skeleton/pubspec.yaml.tmpl | 2 +- 17 files changed, 54 insertions(+), 52 deletions(-) diff --git a/dev/bots/analyze_sample_code.dart b/dev/bots/analyze_sample_code.dart index 910612576f..620472b57e 100644 --- a/dev/bots/analyze_sample_code.dart +++ b/dev/bots/analyze_sample_code.dart @@ -746,9 +746,10 @@ dependencies: sdk: flutter flutter_test: sdk: flutter + vector_math: any dev_dependencies: - flutter_lints: ^1.0.3 + flutter_lints: ^2.0.0 '''); } diff --git a/packages/flutter/lib/src/animation/animation.dart b/packages/flutter/lib/src/animation/animation.dart index 5d6a8e0bd5..8c910833d1 100644 --- a/packages/flutter/lib/src/animation/animation.dart +++ b/packages/flutter/lib/src/animation/animation.dart @@ -135,10 +135,10 @@ abstract class Animation extends Listenable implements ValueListenable { /// vary. /// /// ```dart - /// final Animatable _tween = AlignmentTween(begin: Alignment.topLeft, end: Alignment.topRight) + /// final Animatable tween = AlignmentTween(begin: Alignment.topLeft, end: Alignment.topRight) /// .chain(CurveTween(curve: Curves.easeIn)); /// // ... - /// final Animation _alignment2 = _controller.drive(_tween); + /// final Animation alignment2 = _controller.drive(tween); /// ``` /// {@end-tool} /// {@tool snippet} diff --git a/packages/flutter/lib/src/cupertino/colors.dart b/packages/flutter/lib/src/cupertino/colors.dart index daec593439..5a7f8e2149 100644 --- a/packages/flutter/lib/src/cupertino/colors.dart +++ b/packages/flutter/lib/src/cupertino/colors.dart @@ -598,13 +598,13 @@ class CupertinoColors { /// /// ```dart /// CupertinoButton( -/// child: child, /// // CupertinoDynamicColor works out of box in a CupertinoButton. /// color: const CupertinoDynamicColor.withBrightness( /// color: CupertinoColors.white, /// darkColor: CupertinoColors.black, /// ), /// onPressed: () { }, +/// child: child, /// ) /// ``` /// {@end-tool} diff --git a/packages/flutter/lib/src/cupertino/context_menu.dart b/packages/flutter/lib/src/cupertino/context_menu.dart index 712d516b0d..594c6e561e 100644 --- a/packages/flutter/lib/src/cupertino/context_menu.dart +++ b/packages/flutter/lib/src/cupertino/context_menu.dart @@ -158,10 +158,6 @@ class CupertinoContextMenu extends StatefulWidget { /// /// ```dart /// CupertinoContextMenu( - /// child: FittedBox( - /// fit: BoxFit.cover, - /// child: Image.asset('assets/photo.jpg'), - /// ), /// // The FittedBox in the preview here allows the image to animate its /// // aspect ratio when the CupertinoContextMenu is animating its preview /// // widget open and closed. @@ -184,6 +180,10 @@ class CupertinoContextMenu extends StatefulWidget { /// onPressed: () {}, /// ), /// ], + /// child: FittedBox( + /// fit: BoxFit.cover, + /// child: Image.asset('assets/photo.jpg'), + /// ), /// ) /// ``` /// diff --git a/packages/flutter/lib/src/cupertino/form_row.dart b/packages/flutter/lib/src/cupertino/form_row.dart index 52d0afcb2f..7b40bd3387 100644 --- a/packages/flutter/lib/src/cupertino/form_row.dart +++ b/packages/flutter/lib/src/cupertino/form_row.dart @@ -58,6 +58,9 @@ const EdgeInsetsGeometry _kDefaultPadding = /// header: const Text('SECTION 1'), /// children: [ /// CupertinoFormRow( +/// prefix: const Text('Toggle'), +/// helper: const Text('Use your instincts'), +/// error: toggleValue ? const Text('Cannot be true') : null, /// child: CupertinoSwitch( /// value: toggleValue, /// onChanged: (bool value) { @@ -66,9 +69,6 @@ const EdgeInsetsGeometry _kDefaultPadding = /// }); /// }, /// ), -/// prefix: const Text('Toggle'), -/// helper: const Text('Use your instincts'), -/// error: toggleValue ? const Text('Cannot be true') : null, /// ), /// ], /// ), diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index 124b061d2c..a1644f93d2 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -3162,8 +3162,8 @@ class RenderRepaintBoundary extends RenderProxyBox { /// key: globalKey, /// child: Center( /// child: TextButton( - /// child: const Text('Hello World', textDirection: TextDirection.ltr), /// onPressed: _capturePng, + /// child: const Text('Hello World', textDirection: TextDirection.ltr), /// ), /// ), /// ); diff --git a/packages/flutter/lib/src/widgets/container.dart b/packages/flutter/lib/src/widgets/container.dart index facfad323e..749151ad1b 100644 --- a/packages/flutter/lib/src/widgets/container.dart +++ b/packages/flutter/lib/src/widgets/container.dart @@ -222,12 +222,12 @@ class DecoratedBox extends SingleChildRenderObjectWidget { /// padding: const EdgeInsets.all(8.0), /// color: Colors.blue[600], /// alignment: Alignment.center, +/// transform: Matrix4.rotationZ(0.1), /// child: Text('Hello World', /// style: Theme.of(context) /// .textTheme /// .headline4! /// .copyWith(color: Colors.white)), -/// transform: Matrix4.rotationZ(0.1), /// ) /// ``` /// {@end-tool} diff --git a/packages/flutter/lib/src/widgets/implicit_animations.dart b/packages/flutter/lib/src/widgets/implicit_animations.dart index 9725dfad91..9fba179614 100644 --- a/packages/flutter/lib/src/widgets/implicit_animations.dart +++ b/packages/flutter/lib/src/widgets/implicit_animations.dart @@ -1324,8 +1324,8 @@ class _AnimatedPositionedDirectionalState extends AnimatedWidgetBaseState[ /// ElevatedButton( -/// child: const Text('Scale Logo'), /// onPressed: _changeScale, +/// child: const Text('Scale Logo'), /// ), /// Padding( /// padding: const EdgeInsets.all(50), @@ -1455,8 +1455,8 @@ class _AnimatedScaleState extends ImplicitlyAnimatedWidgetState { /// mainAxisAlignment: MainAxisAlignment.center, /// children: [ /// ElevatedButton( -/// child: const Text('Rotate Logo'), /// onPressed: _changeRotation, +/// child: const Text('Rotate Logo'), /// ), /// Padding( /// padding: const EdgeInsets.all(50), @@ -1673,8 +1673,8 @@ class _AnimatedSlideState extends ImplicitlyAnimatedWidgetState { /// child: const FlutterLogo(), /// ), /// ElevatedButton( -/// child: const Text('Fade Logo'), /// onPressed: _changeOpacity, +/// child: const Text('Fade Logo'), /// ), /// ], /// ); diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index 368cb6a5a0..226104195b 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -586,8 +586,8 @@ mixin LocalHistoryRoute on Route { /// color: Colors.red, /// ) /// : ElevatedButton( - /// child: const Text('Show Rectangle'), /// onPressed: _navigateLocallyToShowRectangle, + /// child: const Text('Show Rectangle'), /// ); /// /// return Scaffold( diff --git a/packages/flutter/lib/src/widgets/scroll_view.dart b/packages/flutter/lib/src/widgets/scroll_view.dart index a7f69bdb82..efc66a233d 100644 --- a/packages/flutter/lib/src/widgets/scroll_view.dart +++ b/packages/flutter/lib/src/widgets/scroll_view.dart @@ -1588,33 +1588,33 @@ class ListView extends BoxScrollView { /// children: [ /// Container( /// padding: const EdgeInsets.all(8), -/// child: const Text("He'd have you all unravel at the"), /// color: Colors.teal[100], +/// child: const Text("He'd have you all unravel at the"), /// ), /// Container( /// padding: const EdgeInsets.all(8), -/// child: const Text('Heed not the rabble'), /// color: Colors.teal[200], +/// child: const Text('Heed not the rabble'), /// ), /// Container( /// padding: const EdgeInsets.all(8), -/// child: const Text('Sound of screams but the'), /// color: Colors.teal[300], +/// child: const Text('Sound of screams but the'), /// ), /// Container( /// padding: const EdgeInsets.all(8), -/// child: const Text('Who scream'), /// color: Colors.teal[400], +/// child: const Text('Who scream'), /// ), /// Container( /// padding: const EdgeInsets.all(8), -/// child: const Text('Revolution is coming...'), /// color: Colors.teal[500], +/// child: const Text('Revolution is coming...'), /// ), /// Container( /// padding: const EdgeInsets.all(8), -/// child: const Text('Revolution, they...'), /// color: Colors.teal[600], +/// child: const Text('Revolution, they...'), /// ), /// ], /// ) @@ -1640,33 +1640,33 @@ class ListView extends BoxScrollView { /// children: [ /// Container( /// padding: const EdgeInsets.all(8), -/// child: const Text("He'd have you all unravel at the"), /// color: Colors.green[100], +/// child: const Text("He'd have you all unravel at the"), /// ), /// Container( /// padding: const EdgeInsets.all(8), -/// child: const Text('Heed not the rabble'), /// color: Colors.green[200], +/// child: const Text('Heed not the rabble'), /// ), /// Container( /// padding: const EdgeInsets.all(8), -/// child: const Text('Sound of screams but the'), /// color: Colors.green[300], +/// child: const Text('Sound of screams but the'), /// ), /// Container( /// padding: const EdgeInsets.all(8), -/// child: const Text('Who scream'), /// color: Colors.green[400], +/// child: const Text('Who scream'), /// ), /// Container( /// padding: const EdgeInsets.all(8), -/// child: const Text('Revolution is coming...'), /// color: Colors.green[500], +/// child: const Text('Revolution is coming...'), /// ), /// Container( /// padding: const EdgeInsets.all(8), -/// child: const Text('Revolution, they...'), /// color: Colors.green[600], +/// child: const Text('Revolution, they...'), /// ), /// ], /// ), diff --git a/packages/flutter/lib/src/widgets/scrollbar.dart b/packages/flutter/lib/src/widgets/scrollbar.dart index 939d4e4136..03d514bbf5 100644 --- a/packages/flutter/lib/src/widgets/scrollbar.dart +++ b/packages/flutter/lib/src/widgets/scrollbar.dart @@ -969,8 +969,8 @@ class RawScrollbar extends StatefulWidget { /// scrollbar dragging for multiple independent ListViews: /// /// ```dart - /// final ScrollController _controllerOne = ScrollController(); - /// final ScrollController _controllerTwo = ScrollController(); + /// final ScrollController controllerOne = ScrollController(); + /// final ScrollController controllerTwo = ScrollController(); /// /// Widget build(BuildContext context) { /// return Column( @@ -978,9 +978,9 @@ class RawScrollbar extends StatefulWidget { /// SizedBox( /// height: 200, /// child: CupertinoScrollbar( - /// controller: _controllerOne, + /// controller: controllerOne, /// child: ListView.builder( - /// controller: _controllerOne, + /// controller: controllerOne, /// itemCount: 120, /// itemBuilder: (BuildContext context, int index) => Text('item $index'), /// ), @@ -989,9 +989,9 @@ class RawScrollbar extends StatefulWidget { /// SizedBox( /// height: 200, /// child: CupertinoScrollbar( - /// controller: _controllerTwo, + /// controller: controllerTwo, /// child: ListView.builder( - /// controller: _controllerTwo, + /// controller: controllerTwo, /// itemCount: 120, /// itemBuilder: (BuildContext context, int index) => Text('list 2 item $index'), /// ), @@ -1030,8 +1030,8 @@ class RawScrollbar extends StatefulWidget { /// {@tool snippet} /// /// ```dart - /// final ScrollController _controllerOne = ScrollController(); - /// final ScrollController _controllerTwo = ScrollController(); + /// final ScrollController controllerOne = ScrollController(); + /// final ScrollController controllerTwo = ScrollController(); /// /// Widget build(BuildContext context) { /// return Column( @@ -1040,9 +1040,9 @@ class RawScrollbar extends StatefulWidget { /// height: 200, /// child: Scrollbar( /// thumbVisibility: true, - /// controller: _controllerOne, + /// controller: controllerOne, /// child: ListView.builder( - /// controller: _controllerOne, + /// controller: controllerOne, /// itemCount: 120, /// itemBuilder: (BuildContext context, int index) { /// return Text('item $index'); @@ -1054,9 +1054,9 @@ class RawScrollbar extends StatefulWidget { /// height: 200, /// child: CupertinoScrollbar( /// thumbVisibility: true, - /// controller: _controllerTwo, + /// controller: controllerTwo, /// child: SingleChildScrollView( - /// controller: _controllerTwo, + /// controller: controllerTwo, /// child: const SizedBox( /// height: 2000, /// width: 500, @@ -1112,8 +1112,8 @@ class RawScrollbar extends StatefulWidget { /// {@tool snippet} /// /// ```dart - /// final ScrollController _controllerOne = ScrollController(); - /// final ScrollController _controllerTwo = ScrollController(); + /// final ScrollController controllerOne = ScrollController(); + /// final ScrollController controllerTwo = ScrollController(); /// /// Widget build(BuildContext context) { /// return Column( @@ -1122,9 +1122,9 @@ class RawScrollbar extends StatefulWidget { /// height: 200, /// child: Scrollbar( /// thumbVisibility: true, - /// controller: _controllerOne, + /// controller: controllerOne, /// child: ListView.builder( - /// controller: _controllerOne, + /// controller: controllerOne, /// itemCount: 120, /// itemBuilder: (BuildContext context, int index) { /// return Text('item $index'); @@ -1136,9 +1136,9 @@ class RawScrollbar extends StatefulWidget { /// height: 200, /// child: CupertinoScrollbar( /// thumbVisibility: true, - /// controller: _controllerTwo, + /// controller: controllerTwo, /// child: SingleChildScrollView( - /// controller: _controllerTwo, + /// controller: controllerTwo, /// child: const SizedBox( /// height: 2000, /// width: 500, diff --git a/packages/flutter_tools/lib/src/flutter_plugins.dart b/packages/flutter_tools/lib/src/flutter_plugins.dart index f9d949d7a1..ba70e91ad1 100644 --- a/packages/flutter_tools/lib/src/flutter_plugins.dart +++ b/packages/flutter_tools/lib/src/flutter_plugins.dart @@ -557,6 +557,7 @@ const String _dartPluginRegistryTemplate = ''' // ignore_for_file: directives_ordering // ignore_for_file: lines_longer_than_80_chars +// ignore_for_file: depend_on_referenced_packages {{#methodChannelPlugins}} import 'package:{{name}}/{{file}}'; diff --git a/packages/flutter_tools/templates/app/pubspec.yaml.tmpl b/packages/flutter_tools/templates/app/pubspec.yaml.tmpl index 2c248a1018..be4df5c5e2 100644 --- a/packages/flutter_tools/templates/app/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/app/pubspec.yaml.tmpl @@ -55,7 +55,7 @@ dev_dependencies: # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. - flutter_lints: ^1.0.0 + flutter_lints: ^2.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl b/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl index 539e0c7fc4..905c56e990 100644 --- a/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl @@ -31,7 +31,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^1.0.0 + flutter_lints: ^2.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/packages/flutter_tools/templates/package/pubspec.yaml.tmpl b/packages/flutter_tools/templates/package/pubspec.yaml.tmpl index 707a35f8bc..7a31800f13 100644 --- a/packages/flutter_tools/templates/package/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/package/pubspec.yaml.tmpl @@ -14,7 +14,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^1.0.0 + flutter_lints: ^2.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/packages/flutter_tools/templates/plugin_shared/pubspec.yaml.tmpl b/packages/flutter_tools/templates/plugin_shared/pubspec.yaml.tmpl index 21061629ef..fecf6a1d96 100644 --- a/packages/flutter_tools/templates/plugin_shared/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/plugin_shared/pubspec.yaml.tmpl @@ -28,7 +28,7 @@ dev_dependencies: {{/withFfiPluginHook}} flutter_test: sdk: flutter - flutter_lints: ^1.0.0 + flutter_lints: ^2.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/packages/flutter_tools/templates/skeleton/pubspec.yaml.tmpl b/packages/flutter_tools/templates/skeleton/pubspec.yaml.tmpl index 3fd79fed80..1f13c8ac18 100644 --- a/packages/flutter_tools/templates/skeleton/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/skeleton/pubspec.yaml.tmpl @@ -19,7 +19,7 @@ dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^1.0.0 + flutter_lints: ^2.0.0 flutter: uses-material-design: true