enable lint unnecessary_const (#19342)

This commit is contained in:
Alexandre Ardhuin
2018-07-16 21:43:48 +02:00
committed by GitHub
parent d10e46ea65
commit cc1cf13eec
556 changed files with 40458 additions and 40457 deletions

View File

@@ -74,7 +74,7 @@ enum TestBindingEventSource {
device,
}
const Size _kDefaultTestViewportSize = const Size(800.0, 600.0);
const Size _kDefaultTestViewportSize = Size(800.0, 600.0);
/// Base class for bindings used by widgets library tests.
///
@@ -346,21 +346,21 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
FlutterExceptionHandler _oldExceptionHandler;
FlutterErrorDetails _pendingExceptionDetails;
static const TextStyle _messageStyle = const TextStyle(
color: const Color(0xFF917FFF),
static const TextStyle _messageStyle = TextStyle(
color: Color(0xFF917FFF),
fontSize: 40.0,
);
static const Widget _preTestMessage = const Center(
child: const Text(
static const Widget _preTestMessage = Center(
child: Text(
'Test starting...',
style: _messageStyle,
textDirection: TextDirection.ltr,
)
);
static const Widget _postTestMessage = const Center(
child: const Text(
static const Widget _postTestMessage = Center(
child: Text(
'Test finished.',
style: _messageStyle,
textDirection: TextDirection.ltr,
@@ -678,7 +678,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
// The timeout here is absurdly high because we do our own timeout logic and
// this is just a backstop.
@override
test_package.Timeout get defaultTestTimeout => const test_package.Timeout(const Duration(minutes: 5));
test_package.Timeout get defaultTestTimeout => const test_package.Timeout(Duration(minutes: 5));
@override
bool get inTest => _currentFakeAsync != null;
@@ -1380,7 +1380,7 @@ class _LiveTestRenderView extends RenderView {
final Map<int, _LiveTestPointerRecord> _pointers = <int, _LiveTestPointerRecord>{};
TextPainter _label;
static const TextStyle _labelStyle = const TextStyle(
static const TextStyle _labelStyle = TextStyle(
fontFamily: 'sans-serif',
fontSize: 10.0,
);

View File

@@ -15,7 +15,7 @@ typedef bool WidgetPredicate(Widget widget);
typedef bool ElementPredicate(Element element);
/// Some frequently used widget [Finder]s.
const CommonFinders find = const CommonFinders._();
const CommonFinders find = CommonFinders._();
/// Provides lightweight syntax for getting frequently used widget [Finder]s.
///

View File

@@ -34,7 +34,7 @@ import 'goldens.dart';
/// * [findsWidgets], when you want the finder to find one or more widgets.
/// * [findsOneWidget], when you want the finder to find exactly one widget.
/// * [findsNWidgets], when you want the finder to find a specific number of widgets.
const Matcher findsNothing = const _FindsWidgetMatcher(null, 0);
const Matcher findsNothing = _FindsWidgetMatcher(null, 0);
/// Asserts that the [Finder] locates at least one widget in the widget tree.
///
@@ -49,7 +49,7 @@ const Matcher findsNothing = const _FindsWidgetMatcher(null, 0);
/// * [findsNothing], when you want the finder to not find anything.
/// * [findsOneWidget], when you want the finder to find exactly one widget.
/// * [findsNWidgets], when you want the finder to find a specific number of widgets.
const Matcher findsWidgets = const _FindsWidgetMatcher(1, null);
const Matcher findsWidgets = _FindsWidgetMatcher(1, null);
/// Asserts that the [Finder] locates at exactly one widget in the widget tree.
///
@@ -64,7 +64,7 @@ const Matcher findsWidgets = const _FindsWidgetMatcher(1, null);
/// * [findsNothing], when you want the finder to not find anything.
/// * [findsWidgets], when you want the finder to find one or more widgets.
/// * [findsNWidgets], when you want the finder to find a specific number of widgets.
const Matcher findsOneWidget = const _FindsWidgetMatcher(1, 1);
const Matcher findsOneWidget = _FindsWidgetMatcher(1, 1);
/// Asserts that the [Finder] locates the specified number of widgets in the widget tree.
///
@@ -96,7 +96,7 @@ Matcher findsNWidgets(int n) => new _FindsWidgetMatcher(n, n);
/// See also:
///
/// * [isOnstage], the opposite.
const Matcher isOffstage = const _IsOffstage();
const Matcher isOffstage = _IsOffstage();
/// Asserts that the [Finder] locates the a single widget that has no
/// [Offstage] widget ancestors.
@@ -104,7 +104,7 @@ const Matcher isOffstage = const _IsOffstage();
/// See also:
///
/// * [isOffstage], the opposite.
const Matcher isOnstage = const _IsOnstage();
const Matcher isOnstage = _IsOnstage();
/// Asserts that the [Finder] locates the a single widget that has at
/// least one [Card] widget ancestor.
@@ -112,7 +112,7 @@ const Matcher isOnstage = const _IsOnstage();
/// See also:
///
/// * [isNotInCard], the opposite.
const Matcher isInCard = const _IsInCard();
const Matcher isInCard = _IsInCard();
/// Asserts that the [Finder] locates the a single widget that has no
/// [Card] widget ancestors.
@@ -122,14 +122,14 @@ const Matcher isInCard = const _IsInCard();
/// See also:
///
/// * [isInCard], the opposite.
const Matcher isNotInCard = const _IsNotInCard();
const Matcher isNotInCard = _IsNotInCard();
/// Asserts that an object's toString() is a plausible one-line description.
///
/// Specifically, this matcher checks that the string does not contains newline
/// characters, and does not have leading or trailing whitespace, is not
/// empty, and does not contain the default `Instance of ...` string.
const Matcher hasOneLineDescription = const _HasOneLineDescription();
const Matcher hasOneLineDescription = _HasOneLineDescription();
/// Asserts that an object's toStringDeep() is a plausible multi-line
/// description.
@@ -146,7 +146,7 @@ const Matcher hasOneLineDescription = const _HasOneLineDescription();
/// * Has multiple lines.
/// * The first line starts with `prefixLineOne`
/// * All subsequent lines start with `prefixOtherLines`.
const Matcher hasAGoodToStringDeep = const _HasGoodToStringDeep();
const Matcher hasAGoodToStringDeep = _HasGoodToStringDeep();
/// A matcher for functions that throw [FlutterError].
///
@@ -800,7 +800,7 @@ typedef num DistanceFunction<T>(T a, T b);
/// first casting it to a [DistanceFunction<T>] for some concrete T.
typedef num AnyDistanceFunction(Null a, Null b);
const Map<Type, AnyDistanceFunction> _kStandardDistanceFunctions = const <Type, AnyDistanceFunction>{
const Map<Type, AnyDistanceFunction> _kStandardDistanceFunctions = <Type, AnyDistanceFunction>{
Color: _maxComponentColorDistance,
HSVColor: _maxComponentHSVColorDistance,
HSLColor: _maxComponentHSLColorDistance,
@@ -1007,7 +1007,7 @@ class _IsMethodCall extends Matcher {
/// Asserts that a [Finder] locates a single object whose root RenderObject
/// is a [RenderClipRect] with no clipper set, or an equivalent
/// [RenderClipPath].
const Matcher clipsWithBoundingRect = const _ClipsWithBoundingRect();
const Matcher clipsWithBoundingRect = _ClipsWithBoundingRect();
/// Asserts that a [Finder] locates a single object whose root RenderObject
/// is a [RenderClipRRect] with no clipper set, and border radius equals to

View File

@@ -14,13 +14,13 @@ void main() {
));
expect(find.text('test'), findsOneWidget);
});
testWidgets('finds Text.rich widgets', (WidgetTester tester) async {
await tester.pumpWidget(_boilerplate(
const Text.rich(
TextSpan(text: 't', children: <TextSpan>[
const TextSpan(text: 'e'),
const TextSpan(text: 'st'),
TextSpan(text: 'e'),
TextSpan(text: 'st'),
]
),
)));

View File

@@ -12,7 +12,7 @@ import 'package:test/test.dart' hide test;
import 'package:flutter_test/flutter_test.dart' show goldenFileComparator, LocalFileComparator;
const List<int> _kExpectedBytes = const <int>[1, 2, 3];
const List<int> _kExpectedBytes = <int>[1, 2, 3];
void main() {
MemoryFileSystem fs;
@@ -171,14 +171,14 @@ void main() {
group('update', () {
test('updates existing file', () async {
fs.file(fix('/golden.png')).writeAsBytesSync(_kExpectedBytes);
const List<int> newBytes = const <int>[11, 12, 13];
const List<int> newBytes = <int>[11, 12, 13];
await comparator.update(fs.file('golden.png').uri, new Uint8List.fromList(newBytes));
expect(fs.file(fix('/golden.png')).readAsBytesSync(), newBytes);
});
test('creates non-existent file', () async {
expect(fs.file(fix('/foo.png')).existsSync(), isFalse);
const List<int> newBytes = const <int>[11, 12, 13];
const List<int> newBytes = <int>[11, 12, 13];
await comparator.update(fs.file('foo.png').uri, new Uint8List.fromList(newBytes));
expect(fs.file(fix('/foo.png')).existsSync(), isTrue);
expect(fs.file(fix('/foo.png')).readAsBytesSync(), newBytes);

View File

@@ -359,7 +359,7 @@ void main() {
testWidgets('if finder finds multiple widgets', (WidgetTester tester) async {
await tester.pumpWidget(boilerplate(new Column(
children: const <Widget>[const Text('hello'), const Text('world')],
children: const <Widget>[Text('hello'), Text('world')],
)));
final Finder finder = find.byType(Text);
try {
@@ -387,7 +387,7 @@ void main() {
group('matchesSemanticsData', () {
testWidgets('matches SemanticsData', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
const Key key = const Key('semantics');
const Key key = Key('semantics');
await tester.pumpWidget(new Semantics(
key: key,
namesRoute: true,

View File

@@ -12,7 +12,7 @@ void main() {
// Setup a widget that can receive focus so that we can open the keyboard.
final Widget widget = new MaterialApp(
home: const Material(
child: const TextField(),
child: TextField(),
),
);
await tester.pumpWidget(widget);

View File

@@ -13,9 +13,9 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:test/test.dart' as test_package;
import 'package:test/src/frontend/async_matcher.dart' show AsyncMatcher;
const List<Widget> fooBarTexts = const <Text>[
const Text('foo', textDirection: TextDirection.ltr),
const Text('bar', textDirection: TextDirection.ltr),
const List<Widget> fooBarTexts = <Text>[
Text('foo', textDirection: TextDirection.ltr),
Text('bar', textDirection: TextDirection.ltr),
];
void main() {
@@ -214,7 +214,7 @@ void main() {
await tester.pumpWidget(new Row(
textDirection: TextDirection.ltr,
children: <Widget>[
new Column(children: const <Text>[const Text('foo', textDirection: TextDirection.ltr)]),
new Column(children: const <Text>[Text('foo', textDirection: TextDirection.ltr)]),
const Text('bar', textDirection: TextDirection.ltr),
],
));
@@ -276,7 +276,7 @@ void main() {
await tester.pumpWidget(new Row(
textDirection: TextDirection.ltr,
children: <Widget>[
new Column(children: const <Text>[const Text('foo', textDirection: TextDirection.ltr)]),
new Column(children: const <Text>[Text('foo', textDirection: TextDirection.ltr)]),
const Text('bar', textDirection: TextDirection.ltr),
],
));
@@ -391,7 +391,7 @@ void main() {
builder: (BuildContext context) {
return new CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: const Text('Page 2'),
middle: Text('Page 2'),
),
child: new Container(),
);
@@ -535,7 +535,7 @@ void main() {
await tester.pumpWidget(
new MaterialApp(
home: const Scaffold(
body: const Text('hello'),
body: Text('hello'),
),
),
);
@@ -552,8 +552,8 @@ void main() {
home: new Scaffold(
body: new Row(
children: const <Widget>[
const Text('hello'),
const Text('hello'),
Text('hello'),
Text('hello'),
],
),
),
@@ -590,7 +590,7 @@ void main() {
testWidgets('Returns merged SemanticsData', (WidgetTester tester) async {
final SemanticsHandle semanticsHandle = tester.ensureSemantics();
const Key key = const Key('test');
const Key key = Key('test');
await tester.pumpWidget(
new MaterialApp(
home: new Scaffold(