lint unnecessary_const on samples (#21155)
This commit is contained in:
committed by
GitHub
parent
c599f99584
commit
3c58195350
@@ -107,6 +107,7 @@ Future<Null> main(List<String> arguments) async {
|
||||
try {
|
||||
final File mainDart = new File(path.join(tempDir.path, 'main.dart'));
|
||||
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;
|
||||
if (arguments.length == 1) {
|
||||
// Used for testing.
|
||||
@@ -212,6 +213,11 @@ dependencies:
|
||||
sdk: flutter
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
''');
|
||||
analysisOptions.writeAsStringSync('''
|
||||
linter:
|
||||
rules:
|
||||
- unnecessary_const
|
||||
''');
|
||||
print('Found $sampleCodeSections sample code sections.');
|
||||
final Process process = await Process.start(
|
||||
|
||||
@@ -135,8 +135,8 @@ class CupertinoSegmentedControl<T> extends StatefulWidget {
|
||||
///
|
||||
/// class SegmentedControlExampleState extends State<SegmentedControlExample> {
|
||||
/// final Map<int, Widget> children = const {
|
||||
/// 0: const Text('Child 1'),
|
||||
/// 1: const Text('Child 2'),
|
||||
/// 0: Text('Child 1'),
|
||||
/// 1: Text('Child 2'),
|
||||
/// };
|
||||
///
|
||||
/// int currentValue;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
/// ```dart
|
||||
/// /// A copper coffee pot, as desired by Ben Turpin.
|
||||
/// /// ...documentation...
|
||||
/// @Category(const <String>['Pots', 'Coffee'])
|
||||
/// @Category(const <String>['Copper', 'Cookware'])
|
||||
/// @Category(<String>['Pots', 'Coffee'])
|
||||
/// @Category(<String>['Copper', 'Cookware'])
|
||||
/// @DocumentationIcon('https://example.com/images/coffee.png')
|
||||
/// @Summary('A proper cup of coffee is made in a proper copper coffee pot.')
|
||||
/// class CopperCoffeePot {
|
||||
@@ -55,7 +55,7 @@ class Category {
|
||||
/// ```dart
|
||||
/// /// Utility class for beginning a dream-sharing sequence.
|
||||
/// /// ...documentation...
|
||||
/// @Category(const <String>['Military Technology', 'Experimental'])
|
||||
/// @Category(<String>['Military Technology', 'Experimental'])
|
||||
/// @DocumentationIcon('https://docs.example.org/icons/top.png')
|
||||
/// class DreamSharing {
|
||||
/// // ...code...
|
||||
@@ -89,8 +89,8 @@ class DocumentationIcon {
|
||||
/// ///
|
||||
/// /// Instances of this class can hunt small animals.
|
||||
/// /// This cat has three legs.
|
||||
/// @Category(const <String>['Animals', 'Cats'])
|
||||
/// @Category(const <String>['Cute', 'Pets'])
|
||||
/// @Category(<String>['Animals', 'Cats'])
|
||||
/// @Category(<String>['Cute', 'Pets'])
|
||||
/// @DocumentationIcon('https://www.examples.net/docs/images/icons/pillar.jpeg')
|
||||
/// @Summary('A famous three-legged cat.')
|
||||
/// class Pillar extends Cat {
|
||||
|
||||
@@ -696,7 +696,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
/// new SliverAppBar(
|
||||
/// expandedHeight: 150.0,
|
||||
/// flexibleSpace: const FlexibleSpaceBar(
|
||||
/// title: const Text('Available seats'),
|
||||
/// title: Text('Available seats'),
|
||||
/// ),
|
||||
/// actions: <Widget>[
|
||||
/// new IconButton(
|
||||
|
||||
@@ -22,9 +22,9 @@ import 'theme.dart';
|
||||
/// mainAxisSize: MainAxisSize.min,
|
||||
/// children: <Widget>[
|
||||
/// const ListTile(
|
||||
/// leading: const Icon(Icons.album),
|
||||
/// title: const Text('The Enchanted Nightingale'),
|
||||
/// subtitle: const Text('Music by Julie Gable. Lyrics by Sidney Stein.'),
|
||||
/// leading: Icon(Icons.album),
|
||||
/// title: Text('The Enchanted Nightingale'),
|
||||
/// subtitle: Text('Music by Julie Gable. Lyrics by Sidney Stein.'),
|
||||
/// ),
|
||||
/// new ButtonTheme.bar( // make buttons use the appropriate styles for cards
|
||||
/// child: new ButtonBar(
|
||||
|
||||
@@ -137,7 +137,7 @@ class _PopupMenuDividerState extends State<PopupMenuDivider> {
|
||||
/// ```dart
|
||||
/// const PopupMenuItem<WhyFarther>(
|
||||
/// 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> {
|
||||
/// const PopupMenuDivider(),
|
||||
/// const PopupMenuItem<Commands>(
|
||||
/// 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
|
||||
/// ],
|
||||
@@ -779,19 +779,19 @@ typedef List<PopupMenuEntry<T>> PopupMenuItemBuilder<T>(BuildContext context);
|
||||
/// itemBuilder: (BuildContext context) => <PopupMenuEntry<WhyFarther>>[
|
||||
/// const PopupMenuItem<WhyFarther>(
|
||||
/// value: WhyFarther.harder,
|
||||
/// child: const Text('Working a lot harder'),
|
||||
/// child: Text('Working a lot harder'),
|
||||
/// ),
|
||||
/// const PopupMenuItem<WhyFarther>(
|
||||
/// value: WhyFarther.smarter,
|
||||
/// child: const Text('Being a lot smarter'),
|
||||
/// child: Text('Being a lot smarter'),
|
||||
/// ),
|
||||
/// const PopupMenuItem<WhyFarther>(
|
||||
/// value: WhyFarther.selfStarter,
|
||||
/// child: const Text('Being a self-starter'),
|
||||
/// child: Text('Being a self-starter'),
|
||||
/// ),
|
||||
/// const PopupMenuItem<WhyFarther>(
|
||||
/// 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 {
|
||||
/// ```dart
|
||||
/// new Container(
|
||||
/// decoration: const BoxDecoration(
|
||||
/// border: const Border(
|
||||
/// top: const BorderSide(width: 1.0, color: const Color(0xFFFFFFFFFF)),
|
||||
/// left: const BorderSide(width: 1.0, color: const Color(0xFFFFFFFFFF)),
|
||||
/// right: const BorderSide(width: 1.0, color: const Color(0xFFFF000000)),
|
||||
/// bottom: const BorderSide(width: 1.0, color: const Color(0xFFFF000000)),
|
||||
/// border: Border(
|
||||
/// top: BorderSide(width: 1.0, color: Color(0xFFFFFFFFFF)),
|
||||
/// left: BorderSide(width: 1.0, color: Color(0xFFFFFFFFFF)),
|
||||
/// right: BorderSide(width: 1.0, color: Color(0xFFFF000000)),
|
||||
/// bottom: BorderSide(width: 1.0, color: Color(0xFFFF000000)),
|
||||
/// ),
|
||||
/// ),
|
||||
/// child: new Container(
|
||||
/// padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 2.0),
|
||||
/// decoration: const BoxDecoration(
|
||||
/// border: const Border(
|
||||
/// top: const BorderSide(width: 1.0, color: const Color(0xFFFFDFDFDF)),
|
||||
/// left: const BorderSide(width: 1.0, color: const Color(0xFFFFDFDFDF)),
|
||||
/// right: const BorderSide(width: 1.0, color: const Color(0xFFFF7F7F7F)),
|
||||
/// bottom: const BorderSide(width: 1.0, color: const Color(0xFFFF7F7F7F)),
|
||||
/// border: Border(
|
||||
/// top: BorderSide(width: 1.0, color: Color(0xFFFFDFDFDF)),
|
||||
/// left: BorderSide(width: 1.0, color: Color(0xFFFFDFDFDF)),
|
||||
/// right: BorderSide(width: 1.0, color: Color(0xFFFF7F7F7F)),
|
||||
/// bottom: BorderSide(width: 1.0, color: Color(0xFFFF7F7F7F)),
|
||||
/// ),
|
||||
/// color: const Color(0xFFBFBFBF),
|
||||
/// color: Color(0xFFBFBFBF),
|
||||
/// ),
|
||||
/// child: const Text(
|
||||
/// 'OK',
|
||||
/// textAlign: TextAlign.center,
|
||||
/// style: const TextStyle(color: const Color(0xFF000000))
|
||||
/// style: TextStyle(color: Color(0xFF000000))
|
||||
/// ),
|
||||
/// ),
|
||||
/// )
|
||||
|
||||
@@ -740,11 +740,11 @@ class RadialGradient extends Gradient {
|
||||
/// startAngle: 0.0,
|
||||
/// endAngle: math.pi * 2,
|
||||
/// colors: const <Color>[
|
||||
/// const Color(0xFF4285F4), // blue
|
||||
/// const Color(0xFF34A853), // green
|
||||
/// const Color(0xFFFBBC05), // yellow
|
||||
/// const Color(0xFFEA4335), // red
|
||||
/// const Color(0xFF4285F4), // blue again to seamlessly transition to the start
|
||||
/// Color(0xFF4285F4), // blue
|
||||
/// Color(0xFF34A853), // green
|
||||
/// Color(0xFFFBBC05), // yellow
|
||||
/// Color(0xFFEA4335), // red
|
||||
/// Color(0xFF4285F4), // blue again to seamlessly transition to the start
|
||||
/// ],
|
||||
/// stops: const <double>[0.0, 0.25, 0.5, 0.75, 1.0],
|
||||
/// ),
|
||||
|
||||
@@ -144,7 +144,7 @@ class MethodChannel {
|
||||
///
|
||||
/// ```dart
|
||||
/// class Music {
|
||||
/// static const MethodChannel _channel = const MethodChannel('music');
|
||||
/// static const MethodChannel _channel = MethodChannel('music');
|
||||
///
|
||||
/// static Future<bool> isLicensed() async {
|
||||
/// // invokeMethod returns a Future<dynamic>, and we cannot pass that for
|
||||
|
||||
@@ -370,7 +370,7 @@ class BackdropFilter extends SingleChildRenderObjectWidget {
|
||||
/// style: const TextStyle(
|
||||
/// fontSize: 40.0,
|
||||
/// fontWeight: FontWeight.w900,
|
||||
/// color: const Color(0xFFFFFFFF),
|
||||
/// color: Color(0xFFFFFFFF),
|
||||
/// ),
|
||||
/// ),
|
||||
/// ),
|
||||
@@ -1360,7 +1360,7 @@ class RotatedBox extends SingleChildRenderObjectWidget {
|
||||
/// ```dart
|
||||
/// new Padding(
|
||||
/// 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 {
|
||||
/// new SizedBox(
|
||||
/// width: 200.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 {
|
||||
/// ```dart
|
||||
/// new ConstrainedBox(
|
||||
/// 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 {
|
||||
/// const SliverAppBar(
|
||||
/// pinned: true,
|
||||
/// expandedHeight: 250.0,
|
||||
/// flexibleSpace: const FlexibleSpaceBar(
|
||||
/// title: const Text('Demo'),
|
||||
/// flexibleSpace: FlexibleSpaceBar(
|
||||
/// title: Text('Demo'),
|
||||
/// ),
|
||||
/// ),
|
||||
/// new SliverGrid(
|
||||
|
||||
@@ -184,11 +184,11 @@ class DefaultTextStyle extends InheritedWidget {
|
||||
///
|
||||
/// ```dart
|
||||
/// const Text.rich(
|
||||
/// const TextSpan(
|
||||
/// TextSpan(
|
||||
/// text: 'Hello', // default text style
|
||||
/// children: const <TextSpan>[
|
||||
/// const TextSpan(text: ' beautiful ', style: const TextStyle(fontStyle: FontStyle.italic)),
|
||||
/// const TextSpan(text: 'world', style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
/// children: <TextSpan>[
|
||||
/// TextSpan(text: ' beautiful ', style: TextStyle(fontStyle: FontStyle.italic)),
|
||||
/// TextSpan(text: 'world', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
/// ],
|
||||
/// ),
|
||||
/// )
|
||||
|
||||
Reference in New Issue
Block a user