Unverified Commit 3c581953 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

lint unnecessary_const on samples (#21155)

parent c599f995
...@@ -107,6 +107,7 @@ Future<Null> main(List<String> arguments) async { ...@@ -107,6 +107,7 @@ Future<Null> main(List<String> arguments) async {
try { try {
final File mainDart = new File(path.join(tempDir.path, 'main.dart')); final File mainDart = new File(path.join(tempDir.path, 'main.dart'));
final File pubSpec = new File(path.join(tempDir.path, 'pubspec.yaml')); final File pubSpec = new File(path.join(tempDir.path, 'pubspec.yaml'));
final File analysisOptions = new File(path.join(tempDir.path, 'analysis_options.yaml'));
Directory flutterPackage; Directory flutterPackage;
if (arguments.length == 1) { if (arguments.length == 1) {
// Used for testing. // Used for testing.
...@@ -212,6 +213,11 @@ dependencies: ...@@ -212,6 +213,11 @@ dependencies:
sdk: flutter sdk: flutter
flutter_test: flutter_test:
sdk: flutter sdk: flutter
''');
analysisOptions.writeAsStringSync('''
linter:
rules:
- unnecessary_const
'''); ''');
print('Found $sampleCodeSections sample code sections.'); print('Found $sampleCodeSections sample code sections.');
final Process process = await Process.start( final Process process = await Process.start(
......
...@@ -135,8 +135,8 @@ class CupertinoSegmentedControl<T> extends StatefulWidget { ...@@ -135,8 +135,8 @@ class CupertinoSegmentedControl<T> extends StatefulWidget {
/// ///
/// class SegmentedControlExampleState extends State<SegmentedControlExample> { /// class SegmentedControlExampleState extends State<SegmentedControlExample> {
/// final Map<int, Widget> children = const { /// final Map<int, Widget> children = const {
/// 0: const Text('Child 1'), /// 0: Text('Child 1'),
/// 1: const Text('Child 2'), /// 1: Text('Child 2'),
/// }; /// };
/// ///
/// int currentValue; /// int currentValue;
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
/// ```dart /// ```dart
/// /// A copper coffee pot, as desired by Ben Turpin. /// /// A copper coffee pot, as desired by Ben Turpin.
/// /// ...documentation... /// /// ...documentation...
/// @Category(const <String>['Pots', 'Coffee']) /// @Category(<String>['Pots', 'Coffee'])
/// @Category(const <String>['Copper', 'Cookware']) /// @Category(<String>['Copper', 'Cookware'])
/// @DocumentationIcon('https://example.com/images/coffee.png') /// @DocumentationIcon('https://example.com/images/coffee.png')
/// @Summary('A proper cup of coffee is made in a proper copper coffee pot.') /// @Summary('A proper cup of coffee is made in a proper copper coffee pot.')
/// class CopperCoffeePot { /// class CopperCoffeePot {
...@@ -55,7 +55,7 @@ class Category { ...@@ -55,7 +55,7 @@ class Category {
/// ```dart /// ```dart
/// /// Utility class for beginning a dream-sharing sequence. /// /// Utility class for beginning a dream-sharing sequence.
/// /// ...documentation... /// /// ...documentation...
/// @Category(const <String>['Military Technology', 'Experimental']) /// @Category(<String>['Military Technology', 'Experimental'])
/// @DocumentationIcon('https://docs.example.org/icons/top.png') /// @DocumentationIcon('https://docs.example.org/icons/top.png')
/// class DreamSharing { /// class DreamSharing {
/// // ...code... /// // ...code...
...@@ -89,8 +89,8 @@ class DocumentationIcon { ...@@ -89,8 +89,8 @@ class DocumentationIcon {
/// /// /// ///
/// /// Instances of this class can hunt small animals. /// /// Instances of this class can hunt small animals.
/// /// This cat has three legs. /// /// This cat has three legs.
/// @Category(const <String>['Animals', 'Cats']) /// @Category(<String>['Animals', 'Cats'])
/// @Category(const <String>['Cute', 'Pets']) /// @Category(<String>['Cute', 'Pets'])
/// @DocumentationIcon('https://www.examples.net/docs/images/icons/pillar.jpeg') /// @DocumentationIcon('https://www.examples.net/docs/images/icons/pillar.jpeg')
/// @Summary('A famous three-legged cat.') /// @Summary('A famous three-legged cat.')
/// class Pillar extends Cat { /// class Pillar extends Cat {
......
...@@ -696,7 +696,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { ...@@ -696,7 +696,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
/// new SliverAppBar( /// new SliverAppBar(
/// expandedHeight: 150.0, /// expandedHeight: 150.0,
/// flexibleSpace: const FlexibleSpaceBar( /// flexibleSpace: const FlexibleSpaceBar(
/// title: const Text('Available seats'), /// title: Text('Available seats'),
/// ), /// ),
/// actions: <Widget>[ /// actions: <Widget>[
/// new IconButton( /// new IconButton(
......
...@@ -22,9 +22,9 @@ import 'theme.dart'; ...@@ -22,9 +22,9 @@ import 'theme.dart';
/// mainAxisSize: MainAxisSize.min, /// mainAxisSize: MainAxisSize.min,
/// children: <Widget>[ /// children: <Widget>[
/// const ListTile( /// const ListTile(
/// leading: const Icon(Icons.album), /// leading: Icon(Icons.album),
/// title: const Text('The Enchanted Nightingale'), /// title: Text('The Enchanted Nightingale'),
/// subtitle: const Text('Music by Julie Gable. Lyrics by Sidney Stein.'), /// subtitle: Text('Music by Julie Gable. Lyrics by Sidney Stein.'),
/// ), /// ),
/// new ButtonTheme.bar( // make buttons use the appropriate styles for cards /// new ButtonTheme.bar( // make buttons use the appropriate styles for cards
/// child: new ButtonBar( /// child: new ButtonBar(
......
...@@ -137,7 +137,7 @@ class _PopupMenuDividerState extends State<PopupMenuDivider> { ...@@ -137,7 +137,7 @@ class _PopupMenuDividerState extends State<PopupMenuDivider> {
/// ```dart /// ```dart
/// const PopupMenuItem<WhyFarther>( /// const PopupMenuItem<WhyFarther>(
/// value: WhyFarther.harder, /// value: WhyFarther.harder,
/// child: const Text('Working a lot harder'), /// child: Text('Working a lot harder'),
/// ) /// )
/// ``` /// ```
/// ///
...@@ -312,7 +312,7 @@ class PopupMenuItemState<T, W extends PopupMenuItem<T>> extends State<W> { ...@@ -312,7 +312,7 @@ class PopupMenuItemState<T, W extends PopupMenuItem<T>> extends State<W> {
/// const PopupMenuDivider(), /// const PopupMenuDivider(),
/// const PopupMenuItem<Commands>( /// const PopupMenuItem<Commands>(
/// value: Commands.hurricaneCame, /// value: Commands.hurricaneCame,
/// child: const ListTile(leading: const Icon(null), title: const Text('Bring hurricane')), /// child: ListTile(leading: Icon(null), title: Text('Bring hurricane')),
/// ), /// ),
/// // ...other items listed here /// // ...other items listed here
/// ], /// ],
...@@ -779,19 +779,19 @@ typedef List<PopupMenuEntry<T>> PopupMenuItemBuilder<T>(BuildContext context); ...@@ -779,19 +779,19 @@ typedef List<PopupMenuEntry<T>> PopupMenuItemBuilder<T>(BuildContext context);
/// itemBuilder: (BuildContext context) => <PopupMenuEntry<WhyFarther>>[ /// itemBuilder: (BuildContext context) => <PopupMenuEntry<WhyFarther>>[
/// const PopupMenuItem<WhyFarther>( /// const PopupMenuItem<WhyFarther>(
/// value: WhyFarther.harder, /// value: WhyFarther.harder,
/// child: const Text('Working a lot harder'), /// child: Text('Working a lot harder'),
/// ), /// ),
/// const PopupMenuItem<WhyFarther>( /// const PopupMenuItem<WhyFarther>(
/// value: WhyFarther.smarter, /// value: WhyFarther.smarter,
/// child: const Text('Being a lot smarter'), /// child: Text('Being a lot smarter'),
/// ), /// ),
/// const PopupMenuItem<WhyFarther>( /// const PopupMenuItem<WhyFarther>(
/// value: WhyFarther.selfStarter, /// value: WhyFarther.selfStarter,
/// child: const Text('Being a self-starter'), /// child: Text('Being a self-starter'),
/// ), /// ),
/// const PopupMenuItem<WhyFarther>( /// const PopupMenuItem<WhyFarther>(
/// value: WhyFarther.tradingCharter, /// value: WhyFarther.tradingCharter,
/// child: const Text('Placed in charge of trading charter'), /// child: Text('Placed in charge of trading charter'),
/// ), /// ),
/// ], /// ],
/// ) /// )
......
...@@ -265,28 +265,28 @@ abstract class BoxBorder extends ShapeBorder { ...@@ -265,28 +265,28 @@ abstract class BoxBorder extends ShapeBorder {
/// ```dart /// ```dart
/// new Container( /// new Container(
/// decoration: const BoxDecoration( /// decoration: const BoxDecoration(
/// border: const Border( /// border: Border(
/// top: const BorderSide(width: 1.0, color: const Color(0xFFFFFFFFFF)), /// top: BorderSide(width: 1.0, color: Color(0xFFFFFFFFFF)),
/// left: const BorderSide(width: 1.0, color: const Color(0xFFFFFFFFFF)), /// left: BorderSide(width: 1.0, color: Color(0xFFFFFFFFFF)),
/// right: const BorderSide(width: 1.0, color: const Color(0xFFFF000000)), /// right: BorderSide(width: 1.0, color: Color(0xFFFF000000)),
/// bottom: const BorderSide(width: 1.0, color: const Color(0xFFFF000000)), /// bottom: BorderSide(width: 1.0, color: Color(0xFFFF000000)),
/// ), /// ),
/// ), /// ),
/// child: new Container( /// child: new Container(
/// padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 2.0), /// padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 2.0),
/// decoration: const BoxDecoration( /// decoration: const BoxDecoration(
/// border: const Border( /// border: Border(
/// top: const BorderSide(width: 1.0, color: const Color(0xFFFFDFDFDF)), /// top: BorderSide(width: 1.0, color: Color(0xFFFFDFDFDF)),
/// left: const BorderSide(width: 1.0, color: const Color(0xFFFFDFDFDF)), /// left: BorderSide(width: 1.0, color: Color(0xFFFFDFDFDF)),
/// right: const BorderSide(width: 1.0, color: const Color(0xFFFF7F7F7F)), /// right: BorderSide(width: 1.0, color: Color(0xFFFF7F7F7F)),
/// bottom: const BorderSide(width: 1.0, color: const Color(0xFFFF7F7F7F)), /// bottom: BorderSide(width: 1.0, color: Color(0xFFFF7F7F7F)),
/// ), /// ),
/// color: const Color(0xFFBFBFBF), /// color: Color(0xFFBFBFBF),
/// ), /// ),
/// child: const Text( /// child: const Text(
/// 'OK', /// 'OK',
/// textAlign: TextAlign.center, /// textAlign: TextAlign.center,
/// style: const TextStyle(color: const Color(0xFF000000)) /// style: TextStyle(color: Color(0xFF000000))
/// ), /// ),
/// ), /// ),
/// ) /// )
......
...@@ -740,11 +740,11 @@ class RadialGradient extends Gradient { ...@@ -740,11 +740,11 @@ class RadialGradient extends Gradient {
/// startAngle: 0.0, /// startAngle: 0.0,
/// endAngle: math.pi * 2, /// endAngle: math.pi * 2,
/// colors: const <Color>[ /// colors: const <Color>[
/// const Color(0xFF4285F4), // blue /// Color(0xFF4285F4), // blue
/// const Color(0xFF34A853), // green /// Color(0xFF34A853), // green
/// const Color(0xFFFBBC05), // yellow /// Color(0xFFFBBC05), // yellow
/// const Color(0xFFEA4335), // red /// Color(0xFFEA4335), // red
/// const Color(0xFF4285F4), // blue again to seamlessly transition to the start /// Color(0xFF4285F4), // blue again to seamlessly transition to the start
/// ], /// ],
/// stops: const <double>[0.0, 0.25, 0.5, 0.75, 1.0], /// stops: const <double>[0.0, 0.25, 0.5, 0.75, 1.0],
/// ), /// ),
......
...@@ -144,7 +144,7 @@ class MethodChannel { ...@@ -144,7 +144,7 @@ class MethodChannel {
/// ///
/// ```dart /// ```dart
/// class Music { /// class Music {
/// static const MethodChannel _channel = const MethodChannel('music'); /// static const MethodChannel _channel = MethodChannel('music');
/// ///
/// static Future<bool> isLicensed() async { /// static Future<bool> isLicensed() async {
/// // invokeMethod returns a Future<dynamic>, and we cannot pass that for /// // invokeMethod returns a Future<dynamic>, and we cannot pass that for
......
...@@ -370,7 +370,7 @@ class BackdropFilter extends SingleChildRenderObjectWidget { ...@@ -370,7 +370,7 @@ class BackdropFilter extends SingleChildRenderObjectWidget {
/// style: const TextStyle( /// style: const TextStyle(
/// fontSize: 40.0, /// fontSize: 40.0,
/// fontWeight: FontWeight.w900, /// fontWeight: FontWeight.w900,
/// color: const Color(0xFFFFFFFF), /// color: Color(0xFFFFFFFF),
/// ), /// ),
/// ), /// ),
/// ), /// ),
...@@ -1360,7 +1360,7 @@ class RotatedBox extends SingleChildRenderObjectWidget { ...@@ -1360,7 +1360,7 @@ class RotatedBox extends SingleChildRenderObjectWidget {
/// ```dart /// ```dart
/// new Padding( /// new Padding(
/// padding: new EdgeInsets.all(8.0), /// padding: new EdgeInsets.all(8.0),
/// child: const Card(child: const Text('Hello World!')), /// child: const Card(child: Text('Hello World!')),
/// ) /// )
/// ``` /// ```
/// ///
...@@ -1700,7 +1700,7 @@ class CustomMultiChildLayout extends MultiChildRenderObjectWidget { ...@@ -1700,7 +1700,7 @@ class CustomMultiChildLayout extends MultiChildRenderObjectWidget {
/// new SizedBox( /// new SizedBox(
/// width: 200.0, /// width: 200.0,
/// height: 300.0, /// height: 300.0,
/// child: const Card(child: const Text('Hello World!')), /// child: const Card(child: Text('Hello World!')),
/// ) /// )
/// ``` /// ```
/// ///
...@@ -1806,7 +1806,7 @@ class SizedBox extends SingleChildRenderObjectWidget { ...@@ -1806,7 +1806,7 @@ class SizedBox extends SingleChildRenderObjectWidget {
/// ```dart /// ```dart
/// new ConstrainedBox( /// new ConstrainedBox(
/// constraints: const BoxConstraints.expand(), /// constraints: const BoxConstraints.expand(),
/// child: const Card(child: const Text('Hello World!')), /// child: const Card(child: Text('Hello World!')),
/// ) /// )
/// ``` /// ```
/// ///
......
...@@ -279,8 +279,8 @@ abstract class ScrollView extends StatelessWidget { ...@@ -279,8 +279,8 @@ abstract class ScrollView extends StatelessWidget {
/// const SliverAppBar( /// const SliverAppBar(
/// pinned: true, /// pinned: true,
/// expandedHeight: 250.0, /// expandedHeight: 250.0,
/// flexibleSpace: const FlexibleSpaceBar( /// flexibleSpace: FlexibleSpaceBar(
/// title: const Text('Demo'), /// title: Text('Demo'),
/// ), /// ),
/// ), /// ),
/// new SliverGrid( /// new SliverGrid(
......
...@@ -184,11 +184,11 @@ class DefaultTextStyle extends InheritedWidget { ...@@ -184,11 +184,11 @@ class DefaultTextStyle extends InheritedWidget {
/// ///
/// ```dart /// ```dart
/// const Text.rich( /// const Text.rich(
/// const TextSpan( /// TextSpan(
/// text: 'Hello', // default text style /// text: 'Hello', // default text style
/// children: const <TextSpan>[ /// children: <TextSpan>[
/// const TextSpan(text: ' beautiful ', style: const TextStyle(fontStyle: FontStyle.italic)), /// TextSpan(text: ' beautiful ', style: TextStyle(fontStyle: FontStyle.italic)),
/// const TextSpan(text: 'world', style: const TextStyle(fontWeight: FontWeight.bold)), /// TextSpan(text: 'world', style: TextStyle(fontWeight: FontWeight.bold)),
/// ], /// ],
/// ), /// ),
/// ) /// )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment