Commit 3961306b authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by Ian Hickson

enable lints prefer_const_declarations and prefer_const_literals_to_create_immutables (#14848)

parent 7fab7f6d
...@@ -109,8 +109,8 @@ linter: ...@@ -109,8 +109,8 @@ linter:
- prefer_conditional_assignment - prefer_conditional_assignment
- prefer_const_constructors - prefer_const_constructors
- prefer_const_constructors_in_immutables - prefer_const_constructors_in_immutables
# - prefer_const_declarations # not yet tested - prefer_const_declarations
# - prefer_const_literals_to_create_immutables # not yet tested - prefer_const_literals_to_create_immutables
# - prefer_constructors_over_static_methods # not yet tested # - prefer_constructors_over_static_methods # not yet tested
- prefer_contains - prefer_contains
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
......
...@@ -102,8 +102,8 @@ linter: ...@@ -102,8 +102,8 @@ linter:
- prefer_conditional_assignment - prefer_conditional_assignment
- prefer_const_constructors - prefer_const_constructors
- prefer_const_constructors_in_immutables - prefer_const_constructors_in_immutables
# - prefer_const_declarations # not yet tested - prefer_const_declarations
# - prefer_const_literals_to_create_immutables # not yet tested - prefer_const_literals_to_create_immutables
# - prefer_constructors_over_static_methods # not yet tested # - prefer_constructors_over_static_methods # not yet tested
- prefer_contains - prefer_contains
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
......
...@@ -116,7 +116,7 @@ void main() { ...@@ -116,7 +116,7 @@ void main() {
child: new CupertinoAlertDialog( child: new CupertinoAlertDialog(
title: const Text('The Title'), title: const Text('The Title'),
content: new Text('Very long content ' * 20), content: new Text('Very long content ' * 20),
actions: <Widget>[ actions: const <Widget>[
const CupertinoDialogAction( const CupertinoDialogAction(
child: const Text('Cancel'), child: const Text('Cancel'),
), ),
......
...@@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
Widget buildSliverAppBarApp({ bool floating, bool pinned, double expandedHeight, bool snap: false }) { Widget buildSliverAppBarApp({ bool floating, bool pinned, double expandedHeight, bool snap: false }) {
return new Localizations( return new Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[ delegates: const <LocalizationsDelegate<dynamic>>[
DefaultMaterialLocalizations.delegate, DefaultMaterialLocalizations.delegate,
DefaultWidgetsLocalizations.delegate, DefaultWidgetsLocalizations.delegate,
], ],
......
...@@ -241,7 +241,7 @@ void main() { ...@@ -241,7 +241,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new Localizations( new Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[ delegates: const <LocalizationsDelegate<dynamic>>[
DefaultWidgetsLocalizations.delegate, DefaultWidgetsLocalizations.delegate,
DefaultMaterialLocalizations.delegate, DefaultMaterialLocalizations.delegate,
], ],
...@@ -256,7 +256,7 @@ void main() { ...@@ -256,7 +256,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new Localizations( new Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[ delegates: const <LocalizationsDelegate<dynamic>>[
DefaultWidgetsLocalizations.delegate, DefaultWidgetsLocalizations.delegate,
DefaultMaterialLocalizations.delegate, DefaultMaterialLocalizations.delegate,
], ],
...@@ -428,7 +428,7 @@ void main() { ...@@ -428,7 +428,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new Localizations( new Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[ delegates: const <LocalizationsDelegate<dynamic>>[
DefaultWidgetsLocalizations.delegate, DefaultWidgetsLocalizations.delegate,
DefaultMaterialLocalizations.delegate, DefaultMaterialLocalizations.delegate,
], ],
...@@ -468,7 +468,7 @@ void main() { ...@@ -468,7 +468,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new Localizations( new Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[ delegates: const <LocalizationsDelegate<dynamic>>[
DefaultWidgetsLocalizations.delegate, DefaultWidgetsLocalizations.delegate,
DefaultMaterialLocalizations.delegate, DefaultMaterialLocalizations.delegate,
], ],
......
...@@ -236,7 +236,7 @@ void main() { ...@@ -236,7 +236,7 @@ void main() {
await tester.pumpWidget(new Localizations( await tester.pumpWidget(new Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[ delegates: const <LocalizationsDelegate<dynamic>>[
DefaultWidgetsLocalizations.delegate, DefaultWidgetsLocalizations.delegate,
DefaultMaterialLocalizations.delegate, DefaultMaterialLocalizations.delegate,
], ],
......
...@@ -65,7 +65,7 @@ class _TestAppState extends State<TestApp> { ...@@ -65,7 +65,7 @@ class _TestAppState extends State<TestApp> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Localizations( return new Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[ delegates: const <LocalizationsDelegate<dynamic>>[
DefaultWidgetsLocalizations.delegate, DefaultWidgetsLocalizations.delegate,
DefaultMaterialLocalizations.delegate, DefaultMaterialLocalizations.delegate,
], ],
......
...@@ -160,7 +160,7 @@ void main() { ...@@ -160,7 +160,7 @@ void main() {
await tester.pumpWidget(new Localizations( await tester.pumpWidget(new Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[ delegates: const <LocalizationsDelegate<dynamic>>[
DefaultWidgetsLocalizations.delegate, DefaultWidgetsLocalizations.delegate,
DefaultMaterialLocalizations.delegate, DefaultMaterialLocalizations.delegate,
], ],
......
...@@ -442,7 +442,7 @@ class _TestAppState extends State<TestApp> { ...@@ -442,7 +442,7 @@ class _TestAppState extends State<TestApp> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Localizations( return new Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[ delegates: const <LocalizationsDelegate<dynamic>>[
DefaultWidgetsLocalizations.delegate, DefaultWidgetsLocalizations.delegate,
DefaultMaterialLocalizations.delegate, DefaultMaterialLocalizations.delegate,
], ],
......
...@@ -363,7 +363,7 @@ void main() { ...@@ -363,7 +363,7 @@ void main() {
child: const Text('body'), child: const Text('body'),
), ),
), ),
persistentFooterButtons: <Widget>[const Placeholder()], persistentFooterButtons: const <Widget>[const Placeholder()],
), ),
), ),
), ),
...@@ -1056,7 +1056,7 @@ class GeometryListenerState extends State<GeometryListener> { ...@@ -1056,7 +1056,7 @@ class GeometryListenerState extends State<GeometryListener> {
if (geometryListenable != null) if (geometryListenable != null)
geometryListenable.removeListener(onGeometryChanged); geometryListenable.removeListener(onGeometryChanged);
geometryListenable = newListenable; geometryListenable = newListenable;
geometryListenable.addListener(onGeometryChanged); geometryListenable.addListener(onGeometryChanged);
cache = new GeometryCachePainter(geometryListenable); cache = new GeometryCachePainter(geometryListenable);
......
...@@ -360,7 +360,7 @@ void main() { ...@@ -360,7 +360,7 @@ void main() {
), ),
child: new Scaffold( child: new Scaffold(
bottomNavigationBar: new BottomNavigationBar( bottomNavigationBar: new BottomNavigationBar(
items: <BottomNavigationBarItem>[ items: const <BottomNavigationBarItem>[
const BottomNavigationBarItem(icon: const Icon(Icons.favorite), title: const Text('Animutation')), const BottomNavigationBarItem(icon: const Icon(Icons.favorite), title: const Text('Animutation')),
const BottomNavigationBarItem(icon: const Icon(Icons.block), title: const Text('Zombo.com')), const BottomNavigationBarItem(icon: const Icon(Icons.block), title: const Text('Zombo.com')),
], ],
......
...@@ -17,7 +17,7 @@ import '../widgets/semantics_tester.dart'; ...@@ -17,7 +17,7 @@ import '../widgets/semantics_tester.dart';
Widget boilerplate({ Widget child, TextDirection textDirection: TextDirection.ltr }) { Widget boilerplate({ Widget child, TextDirection textDirection: TextDirection.ltr }) {
return new Localizations( return new Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[ delegates: const <LocalizationsDelegate<dynamic>>[
DefaultMaterialLocalizations.delegate, DefaultMaterialLocalizations.delegate,
DefaultWidgetsLocalizations.delegate, DefaultWidgetsLocalizations.delegate,
], ],
...@@ -1661,7 +1661,7 @@ void main() { ...@@ -1661,7 +1661,7 @@ void main() {
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: new TabBar( child: new TabBar(
controller: controller, controller: controller,
tabs: <Tab>[ tabs: const <Tab>[
const Tab(text: 'LEFT'), const Tab(text: 'LEFT'),
const Tab(text: 'RIGHT'), const Tab(text: 'RIGHT'),
], ],
......
...@@ -229,7 +229,7 @@ void _tests() { ...@@ -229,7 +229,7 @@ void _tests() {
await tester.pumpWidget( await tester.pumpWidget(
new Localizations( new Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[ delegates: const <LocalizationsDelegate<dynamic>>[
DefaultMaterialLocalizations.delegate, DefaultMaterialLocalizations.delegate,
DefaultWidgetsLocalizations.delegate, DefaultWidgetsLocalizations.delegate,
], ],
......
...@@ -25,7 +25,7 @@ class _CustomPhysics extends ClampingScrollPhysics { ...@@ -25,7 +25,7 @@ class _CustomPhysics extends ClampingScrollPhysics {
Widget buildTest({ ScrollController controller, String title:'TTTTTTTT' }) { Widget buildTest({ ScrollController controller, String title:'TTTTTTTT' }) {
return new Localizations( return new Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[ delegates: const <LocalizationsDelegate<dynamic>>[
DefaultMaterialLocalizations.delegate, DefaultMaterialLocalizations.delegate,
DefaultWidgetsLocalizations.delegate, DefaultWidgetsLocalizations.delegate,
], ],
......
...@@ -253,7 +253,7 @@ void main() { ...@@ -253,7 +253,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new Stack( new Stack(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
children: <Widget>[ children: const <Widget>[
const Positioned( const Positioned(
top: 5.0, top: 5.0,
bottom: 8.0, bottom: 8.0,
...@@ -275,7 +275,7 @@ void main() { ...@@ -275,7 +275,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new Container( new Container(
child: new Row( child: new Row(
children: <Widget>[ children: const <Widget>[
const Positioned( const Positioned(
top: 6.0, top: 6.0,
left: 7.0, left: 7.0,
......
...@@ -913,7 +913,7 @@ void main() { ...@@ -913,7 +913,7 @@ void main() {
const Text('Label 1'), const Text('Label 1'),
const Text('Label 2'), const Text('Label 2'),
new Row( new Row(
children: <Widget>[ children: const <Widget>[
const Text('Label 3'), const Text('Label 3'),
const Text('Label 4'), const Text('Label 4'),
const Text('Label 5'), const Text('Label 5'),
...@@ -976,7 +976,7 @@ void main() { ...@@ -976,7 +976,7 @@ void main() {
new Transform.rotate( new Transform.rotate(
angle: pi / 2.0, angle: pi / 2.0,
child: new Row( child: new Row(
children: <Widget>[ children: const <Widget>[
const Text('Label 3'), const Text('Label 3'),
const Text('Label 4'), const Text('Label 4'),
const Text('Label 5'), const Text('Label 5'),
......
...@@ -15,7 +15,7 @@ void main() { ...@@ -15,7 +15,7 @@ void main() {
data: const MediaQueryData(), data: const MediaQueryData(),
child: new CustomScrollView( child: new CustomScrollView(
controller: controller, controller: controller,
slivers: <Widget>[ slivers: const <Widget>[
const SliverAppBar(floating: true, pinned: true, expandedHeight: 200.0, title: const Text('A')), const SliverAppBar(floating: true, pinned: true, expandedHeight: 200.0, title: const Text('A')),
const SliverAppBar(primary: false, pinned: true, title: const Text('B')), const SliverAppBar(primary: false, pinned: true, title: const Text('B')),
const SliverList( const SliverList(
......
...@@ -14,7 +14,7 @@ Future<Null> test(WidgetTester tester, double offset) { ...@@ -14,7 +14,7 @@ Future<Null> test(WidgetTester tester, double offset) {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: new Viewport( child: new Viewport(
offset: new ViewportOffset.fixed(offset), offset: new ViewportOffset.fixed(offset),
slivers: <Widget>[ slivers: const <Widget>[
const SliverList( const SliverList(
delegate: const SliverChildListDelegate(const <Widget>[ delegate: const SliverChildListDelegate(const <Widget>[
const SizedBox(height: 400.0, child: const Text('a')), const SizedBox(height: 400.0, child: const Text('a')),
...@@ -150,7 +150,7 @@ void main() { ...@@ -150,7 +150,7 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: new Viewport( child: new Viewport(
offset: offset, offset: offset,
slivers: <Widget>[ slivers: const <Widget>[
const SliverList( const SliverList(
delegate: const SliverChildListDelegate(const <Widget>[ delegate: const SliverChildListDelegate(const <Widget>[
const SizedBox(height: 251.0, child: const Text('a')), const SizedBox(height: 251.0, child: const Text('a')),
...@@ -261,7 +261,7 @@ void main() { ...@@ -261,7 +261,7 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: new Viewport( child: new Viewport(
offset: new ViewportOffset.zero(), offset: new ViewportOffset.zero(),
slivers: <Widget>[ slivers: const <Widget>[
const SliverList( const SliverList(
delegate: const SliverChildListDelegate(const <Widget>[ delegate: const SliverChildListDelegate(const <Widget>[
const SizedBox(height: 400.0, child: const Text('a')), const SizedBox(height: 400.0, child: const Text('a')),
...@@ -279,7 +279,7 @@ void main() { ...@@ -279,7 +279,7 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: new Viewport( child: new Viewport(
offset: new ViewportOffset.fixed(100.0), offset: new ViewportOffset.fixed(100.0),
slivers: <Widget>[ slivers: const <Widget>[
const SliverList( const SliverList(
delegate: const SliverChildListDelegate(const <Widget>[ delegate: const SliverChildListDelegate(const <Widget>[
const SizedBox(height: 400.0, child: const Text('a')), const SizedBox(height: 400.0, child: const Text('a')),
...@@ -297,7 +297,7 @@ void main() { ...@@ -297,7 +297,7 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: new Viewport( child: new Viewport(
offset: new ViewportOffset.fixed(100.0), offset: new ViewportOffset.fixed(100.0),
slivers: <Widget>[ slivers: const <Widget>[
const SliverList( const SliverList(
delegate: const SliverChildListDelegate(const <Widget>[ delegate: const SliverChildListDelegate(const <Widget>[
const SizedBox(height: 4000.0, child: const Text('a')), const SizedBox(height: 4000.0, child: const Text('a')),
...@@ -315,7 +315,7 @@ void main() { ...@@ -315,7 +315,7 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: new Viewport( child: new Viewport(
offset: new ViewportOffset.zero(), offset: new ViewportOffset.zero(),
slivers: <Widget>[ slivers: const <Widget>[
const SliverList( const SliverList(
delegate: const SliverChildListDelegate(const <Widget>[ delegate: const SliverChildListDelegate(const <Widget>[
const SizedBox(height: 4000.0, child: const Text('a')), const SizedBox(height: 4000.0, child: const Text('a')),
......
...@@ -31,7 +31,7 @@ void main() { ...@@ -31,7 +31,7 @@ void main() {
await tester.pumpWidget(new MaterialApp( await tester.pumpWidget(new MaterialApp(
supportedLocales: <Locale>[locale], supportedLocales: <Locale>[locale],
locale: locale, locale: locale,
localizationsDelegates: <LocalizationsDelegate<dynamic>>[ localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
GlobalMaterialLocalizations.delegate, GlobalMaterialLocalizations.delegate,
], ],
home: new Builder(builder: (BuildContext context) { home: new Builder(builder: (BuildContext context) {
...@@ -85,7 +85,7 @@ void main() { ...@@ -85,7 +85,7 @@ void main() {
await tester.pumpWidget(new MaterialApp( await tester.pumpWidget(new MaterialApp(
supportedLocales: <Locale>[locale], supportedLocales: <Locale>[locale],
locale: locale, locale: locale,
localizationsDelegates: <LocalizationsDelegate<dynamic>>[ localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
GlobalMaterialLocalizations.delegate, GlobalMaterialLocalizations.delegate,
], ],
home: new Builder(builder: (BuildContext context) { home: new Builder(builder: (BuildContext context) {
......
...@@ -15,7 +15,7 @@ import 'context.dart'; ...@@ -15,7 +15,7 @@ import 'context.dart';
import 'file_system.dart'; import 'file_system.dart';
import 'platform.dart'; import 'platform.dart';
final BotDetector _kBotDetector = const BotDetector(); const BotDetector _kBotDetector = const BotDetector();
class BotDetector { class BotDetector {
const BotDetector(); const BotDetector();
......
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