Commit bb4f4070 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

Prefer const constructors (#11853)

* upgrade to linter-0.1.35

* re-enable lint prefer_const_constructors

* address review comments
parent f0bf7b5c
...@@ -71,6 +71,7 @@ linter: ...@@ -71,6 +71,7 @@ linter:
# === style rules === # === style rules ===
- always_declare_return_types - always_declare_return_types
- always_put_control_body_on_new_line - always_put_control_body_on_new_line
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
- always_require_non_null_named_parameters - always_require_non_null_named_parameters
- always_specify_types - always_specify_types
- annotate_overrides - annotate_overrides
...@@ -108,9 +109,11 @@ linter: ...@@ -108,9 +109,11 @@ linter:
- package_prefixed_library_names - package_prefixed_library_names
# - parameter_assignments # we do this commonly # - parameter_assignments # we do this commonly
- prefer_adjacent_string_concatenation - prefer_adjacent_string_concatenation
# - prefer_asserts_in_initializer_lists # not yet tested
- prefer_collection_literals - prefer_collection_literals
# - prefer_conditional_assignment # not yet tested # - prefer_conditional_assignment # not yet tested
# - prefer_const_constructors # https://github.com/dart-lang/linter/issues/752 - prefer_const_constructors
# - prefer_const_constructors_in_immutables # not yet tested
# - 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
...@@ -122,6 +125,7 @@ linter: ...@@ -122,6 +125,7 @@ linter:
# - prefer_interpolation_to_compose_strings # not yet tested # - prefer_interpolation_to_compose_strings # not yet tested
- prefer_is_empty - prefer_is_empty
- prefer_is_not_empty - prefer_is_not_empty
# - prefer_single_quote_strings # not yet tested
# - public_member_api_docs # this is the only difference from analysis_options_repo.yaml # - public_member_api_docs # this is the only difference from analysis_options_repo.yaml
# - recursive_getters # https://github.com/dart-lang/linter/issues/452 # - recursive_getters # https://github.com/dart-lang/linter/issues/452
- slash_for_doc_comments - slash_for_doc_comments
......
...@@ -65,6 +65,7 @@ linter: ...@@ -65,6 +65,7 @@ linter:
# === style rules === # === style rules ===
- always_declare_return_types - always_declare_return_types
- always_put_control_body_on_new_line - always_put_control_body_on_new_line
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
- always_require_non_null_named_parameters - always_require_non_null_named_parameters
- always_specify_types - always_specify_types
- annotate_overrides - annotate_overrides
...@@ -102,9 +103,11 @@ linter: ...@@ -102,9 +103,11 @@ linter:
- package_prefixed_library_names - package_prefixed_library_names
# - parameter_assignments # we do this commonly # - parameter_assignments # we do this commonly
- prefer_adjacent_string_concatenation - prefer_adjacent_string_concatenation
# - prefer_asserts_in_initializer_lists # not yet tested
- prefer_collection_literals - prefer_collection_literals
# - prefer_conditional_assignment # not yet tested # - prefer_conditional_assignment # not yet tested
# - prefer_const_constructors # https://github.com/dart-lang/linter/issues/752 - prefer_const_constructors
# - prefer_const_constructors_in_immutables # not yet tested
# - 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,6 +119,7 @@ linter: ...@@ -116,6 +119,7 @@ linter:
# - prefer_interpolation_to_compose_strings # not yet tested # - prefer_interpolation_to_compose_strings # not yet tested
- prefer_is_empty - prefer_is_empty
- prefer_is_not_empty - prefer_is_not_empty
# - prefer_single_quote_strings # not yet tested
- public_member_api_docs # this is the only difference from analysis_options_repo.yaml - public_member_api_docs # this is the only difference from analysis_options_repo.yaml
# - recursive_getters # https://github.com/dart-lang/linter/issues/452 # - recursive_getters # https://github.com/dart-lang/linter/issues/452
- slash_for_doc_comments - slash_for_doc_comments
......
...@@ -98,7 +98,7 @@ void main() { ...@@ -98,7 +98,7 @@ void main() {
if (result != 0) if (result != 0)
throw 'Received unexpected exit code $result from run process.'; throw 'Received unexpected exit code $result from run process.';
print('test: validating that the app has in fact closed...'); print('test: validating that the app has in fact closed...');
await client.done.timeout(new Duration(seconds: 5)); await client.done.timeout(const Duration(seconds: 5));
}); });
return new TaskResult.success(null); return new TaskResult.success(null);
}); });
......
...@@ -18,7 +18,7 @@ class _FlavorState extends State<Flavor> { ...@@ -18,7 +18,7 @@ class _FlavorState extends State<Flavor> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
new MethodChannel('flavor').invokeMethod('getFlavor').then((String flavor) { const MethodChannel('flavor').invokeMethod('getFlavor').then((String flavor) {
setState(() { setState(() {
_flavor = flavor; _flavor = flavor;
}); });
...@@ -27,8 +27,8 @@ class _FlavorState extends State<Flavor> { ...@@ -27,8 +27,8 @@ class _FlavorState extends State<Flavor> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return _flavor == null return _flavor == null
? new Text('Awaiting flavor...') ? const Text('Awaiting flavor...')
: new Text(_flavor, key: const ValueKey<String>('flavor')); : new Text(_flavor, key: const ValueKey<String>('flavor'));
} }
} }
...@@ -16,7 +16,7 @@ Future<TestStepResult> systemNavigatorPop() { ...@@ -16,7 +16,7 @@ Future<TestStepResult> systemNavigatorPop() {
channel.setMessageHandler((String message) async { channel.setMessageHandler((String message) async {
completer.complete( completer.complete(
new TestStepResult('System navigation pop', '', TestStatus.ok)); const TestStepResult('System navigation pop', '', TestStatus.ok));
return ''; return '';
}); });
SystemNavigator.pop(); SystemNavigator.pop();
......
...@@ -318,7 +318,7 @@ class _RenderInspectorOverlay extends RenderBox { ...@@ -318,7 +318,7 @@ class _RenderInspectorOverlay extends RenderBox {
@override @override
void performResize() { void performResize() {
size = constraints.constrain(new Size(double.INFINITY, double.INFINITY)); size = constraints.constrain(const Size(double.INFINITY, double.INFINITY));
} }
@override @override
......
...@@ -181,9 +181,9 @@ void main() { ...@@ -181,9 +181,9 @@ void main() {
)); ));
// Disable slider // Disable slider
await tester.pumpWidget(new Directionality( await tester.pumpWidget(const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: new CupertinoSlider( child: const CupertinoSlider(
value: 0.5, value: 0.5,
onChanged: null, onChanged: null,
), ),
......
...@@ -253,7 +253,7 @@ void main() { ...@@ -253,7 +253,7 @@ void main() {
tester.route(pointer.move(const Offset(30.0, 25.0), timeStamp: const Duration(milliseconds: 30))); tester.route(pointer.move(const Offset(30.0, 25.0), timeStamp: const Duration(milliseconds: 30)));
tester.route(pointer.move(const Offset(40.0, 25.0), timeStamp: const Duration(milliseconds: 40))); tester.route(pointer.move(const Offset(40.0, 25.0), timeStamp: const Duration(milliseconds: 40)));
tester.route(pointer.move(const Offset(50.0, 25.0), timeStamp: const Duration(milliseconds: 50))); tester.route(pointer.move(const Offset(50.0, 25.0), timeStamp: const Duration(milliseconds: 50)));
tester.route(new PointerMoveEvent( tester.route(const PointerMoveEvent(
pointer: 1, pointer: 1,
// Simulate a small synthesized wobble which would have slowed down the // Simulate a small synthesized wobble which would have slowed down the
// horizontal velocity from 1 px/ms and introduced a slight vertical velocity. // horizontal velocity from 1 px/ms and introduced a slight vertical velocity.
......
...@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
testWidgets('ButtonBar default control smoketest', (WidgetTester tester) async { testWidgets('ButtonBar default control smoketest', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: const ButtonBar(), child: const ButtonBar(),
), ),
......
...@@ -178,13 +178,13 @@ void main() { ...@@ -178,13 +178,13 @@ void main() {
}); });
testWidgets('Chip in row works ok', (WidgetTester tester) async { testWidgets('Chip in row works ok', (WidgetTester tester) async {
final TextStyle style = new TextStyle(fontFamily: 'Ahem', fontSize: 10.0); final TextStyle style = const TextStyle(fontFamily: 'Ahem', fontSize: 10.0);
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
home: new Material( home: new Material(
child: new Row( child: new Row(
children: <Widget>[ children: <Widget>[
new Chip(label: new Text('Test'), labelStyle: style), new Chip(label: const Text('Test'), labelStyle: style),
], ],
), ),
), ),
...@@ -197,7 +197,7 @@ void main() { ...@@ -197,7 +197,7 @@ void main() {
home: new Material( home: new Material(
child: new Row( child: new Row(
children: <Widget>[ children: <Widget>[
new Flexible(child: new Chip(label: new Text('Test'), labelStyle: style)), new Flexible(child: new Chip(label: const Text('Test'), labelStyle: style)),
], ],
), ),
), ),
...@@ -210,7 +210,7 @@ void main() { ...@@ -210,7 +210,7 @@ void main() {
home: new Material( home: new Material(
child: new Row( child: new Row(
children: <Widget>[ children: <Widget>[
new Expanded(child: new Chip(label: new Text('Test'), labelStyle: style)), new Expanded(child: new Chip(label: const Text('Test'), labelStyle: style)),
], ],
), ),
), ),
...@@ -228,7 +228,7 @@ void main() { ...@@ -228,7 +228,7 @@ void main() {
child: new Center( child: new Center(
child: new Chip( child: new Chip(
onDeleted: () { }, onDeleted: () { },
label: new Text('ABC'), label: const Text('ABC'),
), ),
), ),
); );
......
...@@ -276,11 +276,11 @@ void main() { ...@@ -276,11 +276,11 @@ void main() {
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => new Material( '/': (BuildContext context) => new Material(
child: new FlatButton( child: new FlatButton(
child: new Text('PUSH'), child: const Text('PUSH'),
onPressed: () { Navigator.of(context).pushNamed('/b'); }, onPressed: () { Navigator.of(context).pushNamed('/b'); },
), ),
), ),
'/b': (BuildContext context) => new Container(child: new Text('HELLO')), '/b': (BuildContext context) => new Container(child: const Text('HELLO')),
}; };
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
......
...@@ -110,7 +110,7 @@ void main() { ...@@ -110,7 +110,7 @@ void main() {
icon: const Icon(Icons.view_carousel), icon: const Icon(Icons.view_carousel),
itemBuilder: simplePopupMenuItemBuilder, itemBuilder: simplePopupMenuItemBuilder,
); );
}, throwsA(new isInstanceOf<AssertionError>())); }, throwsA(const isInstanceOf<AssertionError>()));
}); });
testWidgets('PopupMenuButton creates IconButton when given an icon', (WidgetTester tester) async { testWidgets('PopupMenuButton creates IconButton when given an icon', (WidgetTester tester) async {
......
...@@ -148,11 +148,11 @@ void main() { ...@@ -148,11 +148,11 @@ void main() {
Widget build(TextDirection textDirection) { Widget build(TextDirection textDirection) {
return new Directionality( return new Directionality(
textDirection: textDirection, textDirection: textDirection,
child: new MediaQuery( child: const MediaQuery(
data: const MediaQueryData( data: const MediaQueryData(
padding: const EdgeInsets.only(bottom: 200.0), padding: const EdgeInsets.only(bottom: 200.0),
), ),
child: new Scaffold( child: const Scaffold(
floatingActionButton: const FloatingActionButton( floatingActionButton: const FloatingActionButton(
onPressed: null, onPressed: null,
child: const Text('1'), child: const Text('1'),
......
...@@ -472,10 +472,10 @@ void main() { ...@@ -472,10 +472,10 @@ void main() {
)); ));
// Disable slider // Disable slider
await tester.pumpWidget(new Directionality( await tester.pumpWidget(const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: new Material( child: const Material(
child: new Slider( child: const Slider(
value: 0.5, value: 0.5,
onChanged: null, onChanged: null,
), ),
......
...@@ -52,57 +52,58 @@ void main() { ...@@ -52,57 +52,58 @@ void main() {
}); });
test('EdgeInsets.resolve()', () { test('EdgeInsets.resolve()', () {
expect(new EdgeInsetsDirectional.fromSTEB(10.0, 20.0, 30.0, 40.0).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(10.0, 20.0, 30.0, 40.0)); expect(const EdgeInsetsDirectional.fromSTEB(10.0, 20.0, 30.0, 40.0).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(10.0, 20.0, 30.0, 40.0));
expect(new EdgeInsetsDirectional.fromSTEB(99.0, 98.0, 97.0, 96.0).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(97.0, 98.0, 99.0, 96.0)); expect(const EdgeInsetsDirectional.fromSTEB(99.0, 98.0, 97.0, 96.0).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(97.0, 98.0, 99.0, 96.0));
expect(new EdgeInsetsDirectional.only(start: 963.25).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(963.25, 0.0, 0.0, 0.0)); expect(const EdgeInsetsDirectional.only(start: 963.25).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(963.25, 0.0, 0.0, 0.0));
expect(new EdgeInsetsDirectional.only(top: 963.25).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(0.0, 963.25, 0.0, 0.0)); expect(const EdgeInsetsDirectional.only(top: 963.25).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(0.0, 963.25, 0.0, 0.0));
expect(new EdgeInsetsDirectional.only(end: 963.25).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(0.0, 0.0, 963.25, 0.0)); expect(const EdgeInsetsDirectional.only(end: 963.25).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(0.0, 0.0, 963.25, 0.0));
expect(new EdgeInsetsDirectional.only(bottom: 963.25).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 963.25)); expect(const EdgeInsetsDirectional.only(bottom: 963.25).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 963.25));
expect(new EdgeInsetsDirectional.only(start: 963.25).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(0.0, 0.0, 963.25, 0.0)); expect(const EdgeInsetsDirectional.only(start: 963.25).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(0.0, 0.0, 963.25, 0.0));
expect(new EdgeInsetsDirectional.only(top: 963.25).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(0.0, 963.25, 0.0, 0.0)); expect(const EdgeInsetsDirectional.only(top: 963.25).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(0.0, 963.25, 0.0, 0.0));
expect(new EdgeInsetsDirectional.only(end: 963.25).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(963.25, 0.0, 0.0, 0.0)); expect(const EdgeInsetsDirectional.only(end: 963.25).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(963.25, 0.0, 0.0, 0.0));
expect(new EdgeInsetsDirectional.only(bottom: 963.25).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 963.25)); expect(const EdgeInsetsDirectional.only(bottom: 963.25).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 963.25));
expect(new EdgeInsetsDirectional.only(), new EdgeInsetsDirectional.only()); expect(new EdgeInsetsDirectional.only(), new EdgeInsetsDirectional.only()); // ignore: prefer_const_constructors
expect(new EdgeInsetsDirectional.only(top: 1.0).hashCode, isNot(new EdgeInsetsDirectional.only(bottom: 1.0))); expect(const EdgeInsetsDirectional.only(top: 1.0), isNot(const EdgeInsetsDirectional.only(bottom: 1.0)));
expect(new EdgeInsetsDirectional.fromSTEB(10.0, 20.0, 30.0, 40.0).resolve(TextDirection.ltr), expect(const EdgeInsetsDirectional.fromSTEB(10.0, 20.0, 30.0, 40.0).resolve(TextDirection.ltr),
new EdgeInsetsDirectional.fromSTEB(30.0, 20.0, 10.0, 40.0).resolve(TextDirection.rtl)); const EdgeInsetsDirectional.fromSTEB(30.0, 20.0, 10.0, 40.0).resolve(TextDirection.rtl));
expect(new EdgeInsetsDirectional.fromSTEB(10.0, 20.0, 30.0, 40.0).resolve(TextDirection.ltr), expect(const EdgeInsetsDirectional.fromSTEB(10.0, 20.0, 30.0, 40.0).resolve(TextDirection.ltr),
isNot(new EdgeInsetsDirectional.fromSTEB(30.0, 20.0, 10.0, 40.0).resolve(TextDirection.ltr))); isNot(const EdgeInsetsDirectional.fromSTEB(30.0, 20.0, 10.0, 40.0).resolve(TextDirection.ltr)));
expect(new EdgeInsetsDirectional.fromSTEB(10.0, 20.0, 30.0, 40.0).resolve(TextDirection.ltr), expect(const EdgeInsetsDirectional.fromSTEB(10.0, 20.0, 30.0, 40.0).resolve(TextDirection.ltr),
isNot(new EdgeInsetsDirectional.fromSTEB(10.0, 20.0, 30.0, 40.0).resolve(TextDirection.rtl))); isNot(const EdgeInsetsDirectional.fromSTEB(10.0, 20.0, 30.0, 40.0).resolve(TextDirection.rtl)));
}); });
test('EdgeInsets equality', () { test('EdgeInsets equality', () {
expect(new EdgeInsetsDirectional.only(top: 5.0, bottom: 7.0), new EdgeInsetsDirectional.only(top: 5.0, bottom: 7.0)); final double $5 = 5.0; // we want these instances to be separate instances so that we're not just checking with a single object
expect(new EdgeInsets.only(top: 5.0, bottom: 7.0), new EdgeInsetsDirectional.only(top: 5.0, bottom: 7.0)); expect(new EdgeInsetsDirectional.only(top: $5, bottom: 7.0), new EdgeInsetsDirectional.only(top: $5, bottom: 7.0));
expect(new EdgeInsetsDirectional.only(top: 5.0, bottom: 7.0), new EdgeInsets.only(top: 5.0, bottom: 7.0)); expect(new EdgeInsets.only(top: $5, bottom: 7.0), new EdgeInsetsDirectional.only(top: $5, bottom: 7.0));
expect(new EdgeInsets.only(top: 5.0, bottom: 7.0), new EdgeInsets.only(top: 5.0, bottom: 7.0)); expect(new EdgeInsetsDirectional.only(top: $5, bottom: 7.0), new EdgeInsets.only(top: $5, bottom: 7.0));
expect(new EdgeInsetsDirectional.only(start: 5.0), new EdgeInsetsDirectional.only(start: 5.0)); expect(new EdgeInsets.only(top: $5, bottom: 7.0), new EdgeInsets.only(top: $5, bottom: 7.0));
expect(new EdgeInsets.only(left: 5.0), isNot(new EdgeInsetsDirectional.only(start: 5.0))); expect(new EdgeInsetsDirectional.only(start: $5), new EdgeInsetsDirectional.only(start: $5));
expect(new EdgeInsetsDirectional.only(start: 5.0), isNot(new EdgeInsets.only(left: 5.0))); expect(const EdgeInsets.only(left: 5.0), isNot(const EdgeInsetsDirectional.only(start: 5.0)));
expect(new EdgeInsets.only(left: 5.0), new EdgeInsets.only(left: 5.0)); expect(const EdgeInsetsDirectional.only(start: 5.0), isNot(const EdgeInsets.only(left: 5.0)));
expect(new EdgeInsetsDirectional.only(end: 5.0), new EdgeInsetsDirectional.only(end: 5.0)); expect(new EdgeInsets.only(left: $5), new EdgeInsets.only(left: $5));
expect(new EdgeInsets.only(right: 5.0), isNot(new EdgeInsetsDirectional.only(end: 5.0))); expect(new EdgeInsetsDirectional.only(end: $5), new EdgeInsetsDirectional.only(end: $5));
expect(new EdgeInsetsDirectional.only(end: 5.0), isNot(new EdgeInsets.only(right: 5.0))); expect(const EdgeInsets.only(right: 5.0), isNot(const EdgeInsetsDirectional.only(end: 5.0)));
expect(new EdgeInsets.only(right: 5.0), new EdgeInsets.only(right: 5.0)); expect(const EdgeInsetsDirectional.only(end: 5.0), isNot(const EdgeInsets.only(right: 5.0)));
expect(new EdgeInsetsDirectional.only(end: 5.0).add(new EdgeInsets.only(right: 5.0)), new EdgeInsetsDirectional.only(end: 5.0).add(new EdgeInsets.only(right: 5.0))); expect(new EdgeInsets.only(right: $5), new EdgeInsets.only(right: $5));
expect(new EdgeInsetsDirectional.only(end: 5.0).add(new EdgeInsets.only(right: 5.0)), isNot(new EdgeInsetsDirectional.only(end: 5.0).add(new EdgeInsets.only(left: 5.0)))); expect(const EdgeInsetsDirectional.only(end: 5.0).add(const EdgeInsets.only(right: 5.0)), const EdgeInsetsDirectional.only(end: 5.0).add(const EdgeInsets.only(right: 5.0)));
expect(new EdgeInsetsDirectional.only(top: 1.0).add(new EdgeInsets.only(top: 2.0)), new EdgeInsetsDirectional.only(top: 3.0).add(new EdgeInsets.only(top: 0.0))); expect(const EdgeInsetsDirectional.only(end: 5.0).add(const EdgeInsets.only(right: 5.0)), isNot(const EdgeInsetsDirectional.only(end: 5.0).add(const EdgeInsets.only(left: 5.0))));
expect(new EdgeInsetsDirectional.only(top: 1.0).add(new EdgeInsets.only(top: 2.0)), new EdgeInsets.only(top: 3.0).add(new EdgeInsetsDirectional.only(top: 0.0))); expect(const EdgeInsetsDirectional.only(top: 1.0).add(const EdgeInsets.only(top: 2.0)), const EdgeInsetsDirectional.only(top: 3.0).add(const EdgeInsets.only(top: 0.0)));
expect(new EdgeInsetsDirectional.only(top: 1.0).add(new EdgeInsets.only(top: 2.0)), new EdgeInsetsDirectional.only(top: 3.0)); expect(const EdgeInsetsDirectional.only(top: 1.0).add(const EdgeInsets.only(top: 2.0)), const EdgeInsets.only(top: 3.0).add(const EdgeInsetsDirectional.only(top: 0.0)));
expect(new EdgeInsetsDirectional.only(top: 1.0).add(new EdgeInsets.only(top: 2.0)), new EdgeInsets.only(top: 3.0)); expect(const EdgeInsetsDirectional.only(top: 1.0).add(const EdgeInsets.only(top: 2.0)), const EdgeInsetsDirectional.only(top: 3.0));
expect(const EdgeInsetsDirectional.only(top: 1.0).add(const EdgeInsets.only(top: 2.0)), const EdgeInsets.only(top: 3.0));
}); });
test('EdgeInsetsGeometry.lerp(...)', () { test('EdgeInsetsGeometry.lerp(...)', () {
expect(EdgeInsetsGeometry.lerp(new EdgeInsetsDirectional.only(end: 10.0), null, 0.5), new EdgeInsetsDirectional.only(end: 5.0)); expect(EdgeInsetsGeometry.lerp(const EdgeInsetsDirectional.only(end: 10.0), null, 0.5), const EdgeInsetsDirectional.only(end: 5.0));
expect(EdgeInsetsGeometry.lerp(new EdgeInsetsDirectional.only(start: 10.0), null, 0.5), new EdgeInsetsDirectional.only(start: 5.0)); expect(EdgeInsetsGeometry.lerp(const EdgeInsetsDirectional.only(start: 10.0), null, 0.5), const EdgeInsetsDirectional.only(start: 5.0));
expect(EdgeInsetsGeometry.lerp(new EdgeInsetsDirectional.only(top: 10.0), null, 0.5), new EdgeInsetsDirectional.only(top: 5.0)); expect(EdgeInsetsGeometry.lerp(const EdgeInsetsDirectional.only(top: 10.0), null, 0.5), const EdgeInsetsDirectional.only(top: 5.0));
expect(EdgeInsetsGeometry.lerp(new EdgeInsetsDirectional.only(bottom: 10.0), null, 0.5), new EdgeInsetsDirectional.only(bottom: 5.0)); expect(EdgeInsetsGeometry.lerp(const EdgeInsetsDirectional.only(bottom: 10.0), null, 0.5), const EdgeInsetsDirectional.only(bottom: 5.0));
expect(EdgeInsetsGeometry.lerp(new EdgeInsetsDirectional.only(bottom: 10.0), EdgeInsetsDirectional.zero, 0.5), new EdgeInsetsDirectional.only(bottom: 5.0)); expect(EdgeInsetsGeometry.lerp(const EdgeInsetsDirectional.only(bottom: 10.0), EdgeInsetsDirectional.zero, 0.5), const EdgeInsetsDirectional.only(bottom: 5.0));
expect(EdgeInsetsGeometry.lerp(new EdgeInsetsDirectional.only(bottom: 10.0), EdgeInsets.zero, 0.5), new EdgeInsetsDirectional.only(bottom: 5.0)); expect(EdgeInsetsGeometry.lerp(const EdgeInsetsDirectional.only(bottom: 10.0), EdgeInsets.zero, 0.5), const EdgeInsetsDirectional.only(bottom: 5.0));
expect(EdgeInsetsGeometry.lerp(new EdgeInsetsDirectional.only(start: 10.0), new EdgeInsets.only(left: 20.0), 0.5), new EdgeInsetsDirectional.only(start: 5.0).add(new EdgeInsets.only(left: 10.0))); expect(EdgeInsetsGeometry.lerp(const EdgeInsetsDirectional.only(start: 10.0), const EdgeInsets.only(left: 20.0), 0.5), const EdgeInsetsDirectional.only(start: 5.0).add(const EdgeInsets.only(left: 10.0)));
expect(EdgeInsetsGeometry.lerp(new EdgeInsetsDirectional.only(start: 0.0, bottom: 1.0), new EdgeInsetsDirectional.only(start: 1.0, bottom: 1.0).add(new EdgeInsets.only(right: 2.0, bottom: 0.0)), 0.5), new EdgeInsetsDirectional.only(start: 0.5).add(new EdgeInsets.only(right: 1.0, bottom: 1.0))); expect(EdgeInsetsGeometry.lerp(const EdgeInsetsDirectional.only(start: 0.0, bottom: 1.0), const EdgeInsetsDirectional.only(start: 1.0, bottom: 1.0).add(const EdgeInsets.only(right: 2.0, bottom: 0.0)), 0.5), const EdgeInsetsDirectional.only(start: 0.5).add(const EdgeInsets.only(right: 1.0, bottom: 1.0)));
expect(EdgeInsetsGeometry.lerp(new EdgeInsets.only(left: 0.0, bottom: 1.0), new EdgeInsetsDirectional.only(end: 1.0, bottom: 1.0).add(new EdgeInsets.only(right: 2.0, bottom: 0.0)), 0.5), new EdgeInsetsDirectional.only(start: 0.0, end: 0.5).add(new EdgeInsets.only(right: 1.0, bottom: 1.0))); expect(EdgeInsetsGeometry.lerp(const EdgeInsets.only(left: 0.0, bottom: 1.0), const EdgeInsetsDirectional.only(end: 1.0, bottom: 1.0).add(const EdgeInsets.only(right: 2.0, bottom: 0.0)), 0.5), const EdgeInsetsDirectional.only(start: 0.0, end: 0.5).add(const EdgeInsets.only(right: 1.0, bottom: 1.0)));
}); });
test('EdgeInsetsGeometry.lerp(normal, ...)', () { test('EdgeInsetsGeometry.lerp(normal, ...)', () {
...@@ -168,7 +169,7 @@ void main() { ...@@ -168,7 +169,7 @@ void main() {
test('EdgeInsetsGeometry operators', () { test('EdgeInsetsGeometry operators', () {
final EdgeInsetsGeometry a = const EdgeInsetsDirectional.fromSTEB(1.0, 2.0, 3.0, 5.0).add(EdgeInsets.zero); final EdgeInsetsGeometry a = const EdgeInsetsDirectional.fromSTEB(1.0, 2.0, 3.0, 5.0).add(EdgeInsets.zero);
expect(a, isNot(new isInstanceOf<EdgeInsetsDirectional>())); expect(a, isNot(const isInstanceOf<EdgeInsetsDirectional>()));
expect(a * 2.0, const EdgeInsetsDirectional.fromSTEB(2.0, 4.0, 6.0, 10.0)); expect(a * 2.0, const EdgeInsetsDirectional.fromSTEB(2.0, 4.0, 6.0, 10.0));
expect(a / 2.0, const EdgeInsetsDirectional.fromSTEB(0.5, 1.0, 1.5, 2.5)); expect(a / 2.0, const EdgeInsetsDirectional.fromSTEB(0.5, 1.0, 1.5, 2.5));
expect(a % 2.0, const EdgeInsetsDirectional.fromSTEB(1.0, 0.0, 1.0, 1.0)); expect(a % 2.0, const EdgeInsetsDirectional.fromSTEB(1.0, 0.0, 1.0, 1.0));
...@@ -179,12 +180,12 @@ void main() { ...@@ -179,12 +180,12 @@ void main() {
}); });
test('EdgeInsetsGeometry toString', () { test('EdgeInsetsGeometry toString', () {
expect(new EdgeInsets.only().toString(), 'EdgeInsets.zero'); expect(const EdgeInsets.only().toString(), 'EdgeInsets.zero');
expect(new EdgeInsets.only(top: 1.01, left: 1.01, right: 1.01, bottom: 1.01).toString(), 'EdgeInsets.all(1.0)'); expect(const EdgeInsets.only(top: 1.01, left: 1.01, right: 1.01, bottom: 1.01).toString(), 'EdgeInsets.all(1.0)');
expect(new EdgeInsetsDirectional.only().toString(), 'EdgeInsets.zero'); expect(const EdgeInsetsDirectional.only().toString(), 'EdgeInsets.zero');
expect(new EdgeInsetsDirectional.only(start: 1.01, end: 1.01, top: 1.01, bottom: 1.01).toString(), 'EdgeInsetsDirectional(1.0, 1.0, 1.0, 1.0)'); expect(const EdgeInsetsDirectional.only(start: 1.01, end: 1.01, top: 1.01, bottom: 1.01).toString(), 'EdgeInsetsDirectional(1.0, 1.0, 1.0, 1.0)');
expect((new EdgeInsetsDirectional.only(start: 4.0).add(new EdgeInsets.only(top: 3.0))).toString(), 'EdgeInsetsDirectional(4.0, 3.0, 0.0, 0.0)'); expect((const EdgeInsetsDirectional.only(start: 4.0).add(const EdgeInsets.only(top: 3.0))).toString(), 'EdgeInsetsDirectional(4.0, 3.0, 0.0, 0.0)');
expect((new EdgeInsetsDirectional.only(top: 4.0).add(new EdgeInsets.only(right: 3.0))).toString(), 'EdgeInsets(0.0, 4.0, 3.0, 0.0)'); expect((const EdgeInsetsDirectional.only(top: 4.0).add(const EdgeInsets.only(right: 3.0))).toString(), 'EdgeInsets(0.0, 4.0, 3.0, 0.0)');
expect((new EdgeInsetsDirectional.only(start: 4.0).add(new EdgeInsets.only(left: 3.0))).toString(), 'EdgeInsets(3.0, 0.0, 0.0, 0.0) + EdgeInsetsDirectional(4.0, 0.0, 0.0, 0.0)'); expect((const EdgeInsetsDirectional.only(start: 4.0).add(const EdgeInsets.only(left: 3.0))).toString(), 'EdgeInsets(3.0, 0.0, 0.0, 0.0) + EdgeInsetsDirectional(4.0, 0.0, 0.0, 0.0)');
}); });
} }
...@@ -25,8 +25,8 @@ void main() { ...@@ -25,8 +25,8 @@ void main() {
expect(FractionalOffset.lerp(a, b, 0.25), equals(const FractionalOffset(0.125, 0.0))); expect(FractionalOffset.lerp(a, b, 0.25), equals(const FractionalOffset(0.125, 0.0)));
expect(FractionalOffset.lerp(null, null, 0.25), isNull); expect(FractionalOffset.lerp(null, null, 0.25), isNull);
expect(FractionalOffset.lerp(null, b, 0.25), equals(new FractionalOffset(0.5, 0.5 - 0.125))); expect(FractionalOffset.lerp(null, b, 0.25), equals(const FractionalOffset(0.5, 0.5 - 0.125)));
expect(FractionalOffset.lerp(a, null, 0.25), equals(new FractionalOffset(0.125, 0.125))); expect(FractionalOffset.lerp(a, null, 0.25), equals(const FractionalOffset(0.125, 0.125)));
}); });
test('FractionalOffset.fromOffsetAndSize()', () { test('FractionalOffset.fromOffsetAndSize()', () {
...@@ -40,26 +40,27 @@ void main() { ...@@ -40,26 +40,27 @@ void main() {
}); });
test('FractionalOffsetGeometry.resolve()', () { test('FractionalOffsetGeometry.resolve()', () {
expect(new FractionalOffsetDirectional(0.25, 0.3).resolve(TextDirection.ltr), const FractionalOffset(0.25, 0.3)); expect(const FractionalOffsetDirectional(0.25, 0.3).resolve(TextDirection.ltr), const FractionalOffset(0.25, 0.3));
expect(new FractionalOffsetDirectional(0.25, 0.3).resolve(TextDirection.rtl), const FractionalOffset(0.75, 0.3)); expect(const FractionalOffsetDirectional(0.25, 0.3).resolve(TextDirection.rtl), const FractionalOffset(0.75, 0.3));
expect(new FractionalOffsetDirectional(-0.25, 0.3).resolve(TextDirection.ltr), const FractionalOffset(-0.25, 0.3)); expect(const FractionalOffsetDirectional(-0.25, 0.3).resolve(TextDirection.ltr), const FractionalOffset(-0.25, 0.3));
expect(new FractionalOffsetDirectional(-0.25, 0.3).resolve(TextDirection.rtl), const FractionalOffset(1.25, 0.3)); expect(const FractionalOffsetDirectional(-0.25, 0.3).resolve(TextDirection.rtl), const FractionalOffset(1.25, 0.3));
expect(new FractionalOffsetDirectional(1.25, 0.3).resolve(TextDirection.ltr), const FractionalOffset(1.25, 0.3)); expect(const FractionalOffsetDirectional(1.25, 0.3).resolve(TextDirection.ltr), const FractionalOffset(1.25, 0.3));
expect(new FractionalOffsetDirectional(1.25, 0.3).resolve(TextDirection.rtl), const FractionalOffset(-0.25, 0.3)); expect(const FractionalOffsetDirectional(1.25, 0.3).resolve(TextDirection.rtl), const FractionalOffset(-0.25, 0.3));
expect(new FractionalOffsetDirectional(0.5, -0.3).resolve(TextDirection.ltr), const FractionalOffset(0.5, -0.3)); expect(const FractionalOffsetDirectional(0.5, -0.3).resolve(TextDirection.ltr), const FractionalOffset(0.5, -0.3));
expect(new FractionalOffsetDirectional(0.5, -0.3).resolve(TextDirection.rtl), const FractionalOffset(0.5, -0.3)); expect(const FractionalOffsetDirectional(0.5, -0.3).resolve(TextDirection.rtl), const FractionalOffset(0.5, -0.3));
expect(new FractionalOffsetDirectional(0.0, 0.0).resolve(TextDirection.ltr), const FractionalOffset(0.0, 0.0)); expect(const FractionalOffsetDirectional(0.0, 0.0).resolve(TextDirection.ltr), const FractionalOffset(0.0, 0.0));
expect(new FractionalOffsetDirectional(0.0, 0.0).resolve(TextDirection.rtl), const FractionalOffset(1.0, 0.0)); expect(const FractionalOffsetDirectional(0.0, 0.0).resolve(TextDirection.rtl), const FractionalOffset(1.0, 0.0));
expect(new FractionalOffsetDirectional(1.0, 1.0).resolve(TextDirection.ltr), const FractionalOffset(1.0, 1.0)); expect(const FractionalOffsetDirectional(1.0, 1.0).resolve(TextDirection.ltr), const FractionalOffset(1.0, 1.0));
expect(new FractionalOffsetDirectional(1.0, 1.0).resolve(TextDirection.rtl), const FractionalOffset(0.0, 1.0)); expect(const FractionalOffsetDirectional(1.0, 1.0).resolve(TextDirection.rtl), const FractionalOffset(0.0, 1.0));
expect(new FractionalOffsetDirectional(1.0, 2.0), new FractionalOffsetDirectional(1.0, 2.0)); final double $1 = 1.0; // we want these instances to be separate instances so that we're not just checking with a single object
expect(new FractionalOffsetDirectional(1.0, 2.0).hashCode, isNot(new FractionalOffsetDirectional(2.0, 1.0))); expect(new FractionalOffsetDirectional($1, 2.0), new FractionalOffsetDirectional($1, 2.0));
expect(new FractionalOffsetDirectional(0.0, 0.0).resolve(TextDirection.ltr), expect(const FractionalOffsetDirectional(1.0, 2.0), isNot(const FractionalOffsetDirectional(2.0, 1.0)));
new FractionalOffsetDirectional(1.0, 0.0).resolve(TextDirection.rtl)); expect(const FractionalOffsetDirectional(0.0, 0.0).resolve(TextDirection.ltr),
expect(new FractionalOffsetDirectional(0.0, 0.0).resolve(TextDirection.ltr), const FractionalOffsetDirectional(1.0, 0.0).resolve(TextDirection.rtl));
isNot(new FractionalOffsetDirectional(1.0, 0.0).resolve(TextDirection.ltr))); expect(const FractionalOffsetDirectional(0.0, 0.0).resolve(TextDirection.ltr),
expect(new FractionalOffsetDirectional(1.0, 0.0).resolve(TextDirection.ltr), isNot(const FractionalOffsetDirectional(1.0, 0.0).resolve(TextDirection.ltr)));
isNot(new FractionalOffsetDirectional(1.0, 0.0).resolve(TextDirection.rtl))); expect(const FractionalOffsetDirectional(1.0, 0.0).resolve(TextDirection.ltr),
isNot(const FractionalOffsetDirectional(1.0, 0.0).resolve(TextDirection.rtl)));
}); });
test('FractionalOffsetGeometry.lerp', () { test('FractionalOffsetGeometry.lerp', () {
...@@ -111,34 +112,34 @@ void main() { ...@@ -111,34 +112,34 @@ void main() {
}); });
test('FractionalOffsetGeometry operators', () { test('FractionalOffsetGeometry operators', () {
expect(new FractionalOffsetDirectional(1.0, 2.0) * 2.0, new FractionalOffsetDirectional(2.0, 4.0)); expect(const FractionalOffsetDirectional(1.0, 2.0) * 2.0, const FractionalOffsetDirectional(2.0, 4.0));
expect(new FractionalOffsetDirectional(1.0, 2.0) / 2.0, new FractionalOffsetDirectional(0.5, 1.0)); expect(const FractionalOffsetDirectional(1.0, 2.0) / 2.0, const FractionalOffsetDirectional(0.5, 1.0));
expect(new FractionalOffsetDirectional(1.0, 2.0) % 2.0, new FractionalOffsetDirectional(1.0, 0.0)); expect(const FractionalOffsetDirectional(1.0, 2.0) % 2.0, const FractionalOffsetDirectional(1.0, 0.0));
expect(new FractionalOffsetDirectional(1.0, 2.0) ~/ 2.0, new FractionalOffsetDirectional(0.0, 1.0)); expect(const FractionalOffsetDirectional(1.0, 2.0) ~/ 2.0, const FractionalOffsetDirectional(0.0, 1.0));
expect(FractionalOffset.topLeft.add(new FractionalOffsetDirectional(1.0, 2.0) * 2.0), new FractionalOffsetDirectional(2.0, 4.0)); expect(FractionalOffset.topLeft.add(const FractionalOffsetDirectional(1.0, 2.0) * 2.0), const FractionalOffsetDirectional(2.0, 4.0));
expect(FractionalOffset.topLeft.add(new FractionalOffsetDirectional(1.0, 2.0) / 2.0), new FractionalOffsetDirectional(0.5, 1.0)); expect(FractionalOffset.topLeft.add(const FractionalOffsetDirectional(1.0, 2.0) / 2.0), const FractionalOffsetDirectional(0.5, 1.0));
expect(FractionalOffset.topLeft.add(new FractionalOffsetDirectional(1.0, 2.0) % 2.0), new FractionalOffsetDirectional(1.0, 0.0)); expect(FractionalOffset.topLeft.add(const FractionalOffsetDirectional(1.0, 2.0) % 2.0), const FractionalOffsetDirectional(1.0, 0.0));
expect(FractionalOffset.topLeft.add(new FractionalOffsetDirectional(1.0, 2.0) ~/ 2.0), new FractionalOffsetDirectional(0.0, 1.0)); expect(FractionalOffset.topLeft.add(const FractionalOffsetDirectional(1.0, 2.0) ~/ 2.0), const FractionalOffsetDirectional(0.0, 1.0));
expect(new FractionalOffset(1.0, 2.0) * 2.0, new FractionalOffset(2.0, 4.0)); expect(const FractionalOffset(1.0, 2.0) * 2.0, const FractionalOffset(2.0, 4.0));
expect(new FractionalOffset(1.0, 2.0) / 2.0, new FractionalOffset(0.5, 1.0)); expect(const FractionalOffset(1.0, 2.0) / 2.0, const FractionalOffset(0.5, 1.0));
expect(new FractionalOffset(1.0, 2.0) % 2.0, new FractionalOffset(1.0, 0.0)); expect(const FractionalOffset(1.0, 2.0) % 2.0, const FractionalOffset(1.0, 0.0));
expect(new FractionalOffset(1.0, 2.0) ~/ 2.0, new FractionalOffset(0.0, 1.0)); expect(const FractionalOffset(1.0, 2.0) ~/ 2.0, const FractionalOffset(0.0, 1.0));
}); });
test('FractionalOffsetGeometry operators', () { test('FractionalOffsetGeometry operators', () {
expect(new FractionalOffset(1.0, 2.0) + new FractionalOffset(3.0, 5.0), new FractionalOffset(4.0, 7.0)); expect(const FractionalOffset(1.0, 2.0) + const FractionalOffset(3.0, 5.0), const FractionalOffset(4.0, 7.0));
expect(new FractionalOffset(1.0, 2.0) - new FractionalOffset(3.0, 5.0), new FractionalOffset(-2.0, -3.0)); expect(const FractionalOffset(1.0, 2.0) - const FractionalOffset(3.0, 5.0), const FractionalOffset(-2.0, -3.0));
expect(new FractionalOffsetDirectional(1.0, 2.0) + new FractionalOffsetDirectional(3.0, 5.0), new FractionalOffsetDirectional(4.0, 7.0)); expect(const FractionalOffsetDirectional(1.0, 2.0) + const FractionalOffsetDirectional(3.0, 5.0), const FractionalOffsetDirectional(4.0, 7.0));
expect(new FractionalOffsetDirectional(1.0, 2.0) - new FractionalOffsetDirectional(3.0, 5.0), new FractionalOffsetDirectional(-2.0, -3.0)); expect(const FractionalOffsetDirectional(1.0, 2.0) - const FractionalOffsetDirectional(3.0, 5.0), const FractionalOffsetDirectional(-2.0, -3.0));
}); });
test('FractionalOffsetGeometry toString', () { test('FractionalOffsetGeometry toString', () {
expect(new FractionalOffset(1.0001, 2.0001).toString(), 'FractionalOffset(1.0, 2.0)'); expect(const FractionalOffset(1.0001, 2.0001).toString(), 'FractionalOffset(1.0, 2.0)');
expect(new FractionalOffset(0.0, 0.0).toString(), 'FractionalOffset.topLeft'); expect(const FractionalOffset(0.0, 0.0).toString(), 'FractionalOffset.topLeft');
expect(new FractionalOffset(0.0, 1.0).add(new FractionalOffsetDirectional(1.0, 0.0)).toString(), 'FractionalOffsetDirectional.bottomEnd'); expect(const FractionalOffset(0.0, 1.0).add(const FractionalOffsetDirectional(1.0, 0.0)).toString(), 'FractionalOffsetDirectional.bottomEnd');
expect(new FractionalOffset(0.0001, 0.0001).toString(), 'FractionalOffset(0.0, 0.0)'); expect(const FractionalOffset(0.0001, 0.0001).toString(), 'FractionalOffset(0.0, 0.0)');
expect(new FractionalOffset(0.0, 0.0).toString(), 'FractionalOffset.topLeft'); expect(const FractionalOffset(0.0, 0.0).toString(), 'FractionalOffset.topLeft');
expect(new FractionalOffsetDirectional(0.0, 0.0).toString(), 'FractionalOffsetDirectional.topStart'); expect(const FractionalOffsetDirectional(0.0, 0.0).toString(), 'FractionalOffsetDirectional.topStart');
expect(new FractionalOffset(1.0, 1.0).add(new FractionalOffsetDirectional(1.0, 1.0)).toString(), 'FractionalOffset(1.0, 2.0) + FractionalOffsetDirectional(1.0, 0.0)'); expect(const FractionalOffset(1.0, 1.0).add(const FractionalOffsetDirectional(1.0, 1.0)).toString(), 'FractionalOffset(1.0, 2.0) + FractionalOffsetDirectional(1.0, 0.0)');
}); });
} }
...@@ -358,7 +358,7 @@ void main() { ...@@ -358,7 +358,7 @@ void main() {
expect(exceptions, isEmpty); expect(exceptions, isEmpty);
layout(parent); layout(parent);
expect(exceptions, isNotEmpty); expect(exceptions, isNotEmpty);
expect(exceptions.first, new isInstanceOf<FlutterError>()); expect(exceptions.first, const isInstanceOf<FlutterError>());
}); });
test('MainAxisSize.min inside unconstrained', () { test('MainAxisSize.min inside unconstrained', () {
...@@ -388,7 +388,7 @@ void main() { ...@@ -388,7 +388,7 @@ void main() {
expect(exceptions, isEmpty); expect(exceptions, isEmpty);
layout(parent); layout(parent);
expect(exceptions, isNotEmpty); expect(exceptions, isNotEmpty);
expect(exceptions.first, new isInstanceOf<FlutterError>()); expect(exceptions.first, const isInstanceOf<FlutterError>());
}); });
test('Flex RTL', () { test('Flex RTL', () {
......
...@@ -8,7 +8,8 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -8,7 +8,8 @@ import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
test('NetworkImage non-null url test', () { test('NetworkImage non-null url test', () {
expect(() { expect(() {
new NetworkImage(null); // ignore: prefer_const_constructors final String url = null; // we don't want this instance to be const because otherwise it would throw at compile time.
new NetworkImage(url);
}, throwsAssertionError); }, throwsAssertionError);
}); });
} }
...@@ -11,7 +11,7 @@ void main() { ...@@ -11,7 +11,7 @@ void main() {
final Widget inner = new Builder( final Widget inner = new Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
log.add(Directionality.of(context)); log.add(Directionality.of(context));
return new Placeholder(); return const Placeholder();
} }
); );
await tester.pumpWidget( await tester.pumpWidget(
...@@ -57,13 +57,16 @@ void main() { ...@@ -57,13 +57,16 @@ void main() {
builder: (BuildContext context) { builder: (BuildContext context) {
expect(Directionality.of(context), isNull); expect(Directionality.of(context), isNull);
good = true; good = true;
return new Placeholder(); return const Placeholder();
}, },
)); ));
expect(good, isTrue); expect(good, isTrue);
}); });
testWidgets('Directionality can\'t be null', (WidgetTester tester) async { testWidgets('Directionality can\'t be null', (WidgetTester tester) async {
expect(() { new Directionality(textDirection: null, child: new Placeholder()); }, throwsAssertionError); expect(() {
final TextDirection textDirection = null; // we don't want this instance to be const because otherwise it would throw at compile time.
new Directionality(textDirection: textDirection, child: const Placeholder());
}, throwsAssertionError);
}); });
} }
...@@ -130,7 +130,7 @@ void main() { ...@@ -130,7 +130,7 @@ void main() {
buildFrame( buildFrame(
buildContent: (BuildContext context) { buildContent: (BuildContext context) {
pageContext = context; pageContext = context;
return new Text('Hello World'); return const Text('Hello World');
} }
) )
); );
...@@ -153,7 +153,7 @@ void main() { ...@@ -153,7 +153,7 @@ void main() {
locale: locale, locale: locale,
buildContent: (BuildContext context) { buildContent: (BuildContext context) {
pageContext = context; pageContext = context;
return new Text('Hello World'); return const Text('Hello World');
}, },
) )
); );
...@@ -295,7 +295,7 @@ void main() { ...@@ -295,7 +295,7 @@ void main() {
locale: const Locale('en', 'GB'), locale: const Locale('en', 'GB'),
delegates: <LocalizationsDelegate<dynamic>>[ delegates: <LocalizationsDelegate<dynamic>>[
new SyncTestLocalizationsDelegate(), new SyncTestLocalizationsDelegate(),
new DefaultWidgetsLocalizationsDelegate(), const DefaultWidgetsLocalizationsDelegate(),
], ],
// Create a new context within the en_GB Localization // Create a new context within the en_GB Localization
child: new Builder( child: new Builder(
......
...@@ -7,9 +7,9 @@ import 'package:flutter/widgets.dart'; ...@@ -7,9 +7,9 @@ import 'package:flutter/widgets.dart';
void main() { void main() {
testWidgets('Padding RTL', (WidgetTester tester) async { testWidgets('Padding RTL', (WidgetTester tester) async {
final Widget child = new Padding( final Widget child = const Padding(
padding: new EdgeInsetsDirectional.only(start: 10.0), padding: const EdgeInsetsDirectional.only(start: 10.0),
child: new Placeholder(), child: const Placeholder(),
); );
await tester.pumpWidget(new Directionality( await tester.pumpWidget(new Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -25,9 +25,9 @@ void main() { ...@@ -25,9 +25,9 @@ void main() {
testWidgets('Container padding/margin RTL', (WidgetTester tester) async { testWidgets('Container padding/margin RTL', (WidgetTester tester) async {
final Widget child = new Container( final Widget child = new Container(
padding: new EdgeInsetsDirectional.only(start: 6.0), padding: const EdgeInsetsDirectional.only(start: 6.0),
margin: new EdgeInsetsDirectional.only(end: 20.0, start: 4.0), margin: const EdgeInsetsDirectional.only(end: 20.0, start: 4.0),
child: new Placeholder(), child: const Placeholder(),
); );
await tester.pumpWidget(new Directionality( await tester.pumpWidget(new Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -45,9 +45,9 @@ void main() { ...@@ -45,9 +45,9 @@ void main() {
testWidgets('Container padding/margin mixed RTL/absolute', (WidgetTester tester) async { testWidgets('Container padding/margin mixed RTL/absolute', (WidgetTester tester) async {
final Widget child = new Container( final Widget child = new Container(
padding: new EdgeInsets.only(left: 6.0), padding: const EdgeInsets.only(left: 6.0),
margin: new EdgeInsetsDirectional.only(end: 20.0, start: 4.0), margin: const EdgeInsetsDirectional.only(end: 20.0, start: 4.0),
child: new Placeholder(), child: const Placeholder(),
); );
await tester.pumpWidget(new Directionality( await tester.pumpWidget(new Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -64,7 +64,7 @@ void main() { ...@@ -64,7 +64,7 @@ void main() {
}); });
testWidgets('EdgeInsetsDirectional without Directionality', (WidgetTester tester) async { testWidgets('EdgeInsetsDirectional without Directionality', (WidgetTester tester) async {
await tester.pumpWidget(new Padding(padding: new EdgeInsetsDirectional.only())); await tester.pumpWidget(const Padding(padding: const EdgeInsetsDirectional.only()));
expect(tester.takeException(), isAssertionError); expect(tester.takeException(), isAssertionError);
}); });
} }
...@@ -51,10 +51,10 @@ Widget buildTestWidgets({bool excludeSemantics, String label, bool isSemanticsBo ...@@ -51,10 +51,10 @@ Widget buildTestWidgets({bool excludeSemantics, String label, bool isSemanticsBo
isSemanticBoundary: isSemanticsBoundary, isSemanticBoundary: isSemanticsBoundary,
child: new Column( child: new Column(
children: <Widget>[ children: <Widget>[
new Semantics( const Semantics(
label: 'child1', label: 'child1',
), ),
new Semantics( const Semantics(
label: 'child2', label: 'child2',
), ),
], ],
......
...@@ -13,7 +13,7 @@ void main() { ...@@ -13,7 +13,7 @@ void main() {
testWidgets('markNeedsSemanticsUpdate allways resets node', (WidgetTester tester) async { testWidgets('markNeedsSemanticsUpdate allways resets node', (WidgetTester tester) async {
final SemanticsTester semantics = new SemanticsTester(tester); final SemanticsTester semantics = new SemanticsTester(tester);
await tester.pumpWidget(new TestWidget()); await tester.pumpWidget(const TestWidget());
final RenderTest renderObj = tester.renderObject(find.byType(TestWidget)); final RenderTest renderObj = tester.renderObject(find.byType(TestWidget));
expect(renderObj.labelWasReset, hasLength(1)); expect(renderObj.labelWasReset, hasLength(1));
expect(renderObj.labelWasReset.last, true); expect(renderObj.labelWasReset.last, true);
......
...@@ -29,7 +29,7 @@ void main() { ...@@ -29,7 +29,7 @@ void main() {
child: new CustomScrollView( child: new CustomScrollView(
controller: scrollController, controller: scrollController,
slivers: <Widget>[ slivers: <Widget>[
new SliverAppBar( const SliverAppBar(
pinned: true, pinned: true,
expandedHeight: appBarExpandedHeight, expandedHeight: appBarExpandedHeight,
title: const Text('Semantics Test with Slivers'), title: const Text('Semantics Test with Slivers'),
...@@ -239,7 +239,7 @@ void main() { ...@@ -239,7 +239,7 @@ void main() {
slivers: slivers, slivers: slivers,
), ),
); );
expect(semantics, hasSemantics( expect(semantics, hasSemantics(
new TestSemantics.root( new TestSemantics.root(
children: <TestSemantics>[ children: <TestSemantics>[
...@@ -295,10 +295,10 @@ void main() { ...@@ -295,10 +295,10 @@ void main() {
final ScrollController controller = new ScrollController(initialScrollOffset: 280.0); final ScrollController controller = new ScrollController(initialScrollOffset: 280.0);
await tester.pumpWidget( await tester.pumpWidget(
new MediaQuery( new MediaQuery(
data: new MediaQueryData(), data: const MediaQueryData(),
child: new CustomScrollView( child: new CustomScrollView(
slivers: <Widget>[ slivers: <Widget>[
new SliverAppBar( const SliverAppBar(
pinned: true, pinned: true,
expandedHeight: 100.0, expandedHeight: 100.0,
), ),
...@@ -377,11 +377,11 @@ void main() { ...@@ -377,11 +377,11 @@ void main() {
}); });
await tester.pumpWidget( await tester.pumpWidget(
new MediaQuery( new MediaQuery(
data: new MediaQueryData(), data: const MediaQueryData(),
child: new CustomScrollView( child: new CustomScrollView(
controller: controller, controller: controller,
slivers: <Widget>[ slivers: <Widget>[
new SliverAppBar( const SliverAppBar(
pinned: true, pinned: true,
expandedHeight: 100.0, expandedHeight: 100.0,
), ),
...@@ -454,11 +454,11 @@ void main() { ...@@ -454,11 +454,11 @@ void main() {
final ScrollController controller = new ScrollController(initialScrollOffset: 280.0); final ScrollController controller = new ScrollController(initialScrollOffset: 280.0);
await tester.pumpWidget( await tester.pumpWidget(
new MediaQuery( new MediaQuery(
data: new MediaQueryData(), data: const MediaQueryData(),
child: new CustomScrollView( child: new CustomScrollView(
reverse: true, // This is the important setting for this test. reverse: true, // This is the important setting for this test.
slivers: <Widget>[ slivers: <Widget>[
new SliverAppBar( const SliverAppBar(
pinned: true, pinned: true,
expandedHeight: 100.0, expandedHeight: 100.0,
), ),
...@@ -538,12 +538,12 @@ void main() { ...@@ -538,12 +538,12 @@ void main() {
}); });
await tester.pumpWidget( await tester.pumpWidget(
new MediaQuery( new MediaQuery(
data: new MediaQueryData(), data: const MediaQueryData(),
child: new CustomScrollView( child: new CustomScrollView(
reverse: true, // This is the important setting for this test. reverse: true, // This is the important setting for this test.
controller: controller, controller: controller,
slivers: <Widget>[ slivers: <Widget>[
new SliverAppBar( const SliverAppBar(
pinned: true, pinned: true,
expandedHeight: 100.0, expandedHeight: 100.0,
), ),
...@@ -624,7 +624,7 @@ void main() { ...@@ -624,7 +624,7 @@ void main() {
}); });
await tester.pumpWidget( await tester.pumpWidget(
new MediaQuery( new MediaQuery(
data: new MediaQueryData(), data: const MediaQueryData(),
child: new Scrollable( child: new Scrollable(
controller: controller, controller: controller,
viewportBuilder: (BuildContext context, ViewportOffset offset) { viewportBuilder: (BuildContext context, ViewportOffset offset) {
...@@ -635,7 +635,7 @@ void main() { ...@@ -635,7 +635,7 @@ void main() {
new SliverList( new SliverList(
delegate: new SliverChildListDelegate(backwardChildren), delegate: new SliverChildListDelegate(backwardChildren),
), ),
new SliverAppBar( const SliverAppBar(
pinned: true, pinned: true,
expandedHeight: 100.0, expandedHeight: 100.0,
flexibleSpace: const FlexibleSpaceBar( flexibleSpace: const FlexibleSpaceBar(
......
...@@ -90,7 +90,7 @@ iPhone SE (11.0) [667E8DCD-5DCD-4C80-93A9-60D1D995206F] (Simulator) ...@@ -90,7 +90,7 @@ iPhone SE (11.0) [667E8DCD-5DCD-4C80-93A9-60D1D995206F] (Simulator)
Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt MobileGestalt.c:550: no access to InverseDeviceID (see <rdar://problem/11744455>) Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt MobileGestalt.c:550: no access to InverseDeviceID (see <rdar://problem/11744455>)
Runner(libsystem_asl.dylib)[297] <Notice>: I is for ichigo Runner(libsystem_asl.dylib)[297] <Notice>: I is for ichigo
'''.codeUnits])); '''.codeUnits]));
when(mockProcess.stderr).thenReturn(new Stream<List<int>>.empty()); when(mockProcess.stderr).thenReturn(const Stream<List<int>>.empty());
// Delay return of exitCode until after stdout stream data, since it terminates the logger. // Delay return of exitCode until after stdout stream data, since it terminates the logger.
when(mockProcess.exitCode).thenReturn(new Future<int>.delayed(Duration.ZERO, () => 0)); when(mockProcess.exitCode).thenReturn(new Future<int>.delayed(Duration.ZERO, () => 0));
return new Future<Process>.value(mockProcess); return new Future<Process>.value(mockProcess);
......
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