Declare locals final where not reassigned (gallery) (#8571)
diff --git a/examples/flutter_gallery/lib/demo/calculator/logic.dart b/examples/flutter_gallery/lib/demo/calculator/logic.dart index 214a6c6..bc36b3f 100644 --- a/examples/flutter_gallery/lib/demo/calculator/logic.dart +++ b/examples/flutter_gallery/lib/demo/calculator/logic.dart
@@ -139,7 +139,7 @@ /// in the calculator's display panel. @override String toString() { - StringBuffer buffer = new StringBuffer(''); + final StringBuffer buffer = new StringBuffer(''); buffer.writeAll(_list); return buffer.toString(); } @@ -162,12 +162,12 @@ newToken = new IntToken('-$digit'); break; case ExpressionState.Number: - ExpressionToken last = outList.removeLast(); + final ExpressionToken last = outList.removeLast(); newToken = new IntToken('${last.stringRep}$digit'); break; case ExpressionState.Point: case ExpressionState.NumberWithPoint: - ExpressionToken last = outList.removeLast(); + final ExpressionToken last = outList.removeLast(); newState = ExpressionState.NumberWithPoint; newToken = new FloatToken('${last.stringRep}$digit'); break; @@ -191,7 +191,7 @@ break; case ExpressionState.LeadingNeg: case ExpressionState.Number: - ExpressionToken last = outList.removeLast(); + final ExpressionToken last = outList.removeLast(); newToken = new FloatToken(last.stringRep + '.'); break; case ExpressionState.Point: @@ -282,14 +282,14 @@ // We make a copy of _list because CalcExpressions are supposed to // be immutable. - List<ExpressionToken> list = _list.toList(); + final List<ExpressionToken> list = _list.toList(); // We obey order-of-operations by computing the sum of the 'terms', // where a "term" is defined to be a sequence of numbers separated by // multiplcation or division symbols. num currentTermValue = removeNextTerm(list); while (list.isNotEmpty) { - OperationToken opToken = list.removeAt(0); - num nextTermValue = removeNextTerm(list); + final OperationToken opToken = list.removeAt(0); + final num nextTermValue = removeNextTerm(list); switch (opToken.operation) { case Operation.Addition: currentTermValue += nextTermValue; @@ -317,7 +317,7 @@ num currentValue = firstNumToken.number; while (list.isNotEmpty) { bool isDivision = false; - OperationToken nextOpToken = list.first; + final OperationToken nextOpToken = list.first; switch (nextOpToken.operation) { case Operation.Addition: case Operation.Subtraction: @@ -332,7 +332,7 @@ list.removeAt(0); // Remove the next number token. final NumberToken nextNumToken = list.removeAt(0); - num nextNumber = nextNumToken.number; + final num nextNumber = nextNumToken.number; if (isDivision) currentValue /= nextNumber; else
diff --git a/examples/flutter_gallery/lib/demo/colors_demo.dart b/examples/flutter_gallery/lib/demo/colors_demo.dart index 4cf7279..9ef44d6 100644 --- a/examples/flutter_gallery/lib/demo/colors_demo.dart +++ b/examples/flutter_gallery/lib/demo/colors_demo.dart
@@ -82,7 +82,7 @@ final TextTheme textTheme = Theme.of(context).textTheme; final TextStyle whiteTextStyle = textTheme.body1.copyWith(color: Colors.white); final TextStyle blackTextStyle = textTheme.body1.copyWith(color: Colors.black); - List<Widget> colorItems = swatch.colors.keys.map((int index) { + final List<Widget> colorItems = swatch.colors.keys.map((int index) { return new DefaultTextStyle( style: index > swatch.threshold ? whiteTextStyle : blackTextStyle, child: new ColorItem(index: index, color: swatch.colors[index]),
diff --git a/examples/flutter_gallery/lib/demo/contacts_demo.dart b/examples/flutter_gallery/lib/demo/contacts_demo.dart index 2b9167a..fd184f1 100644 --- a/examples/flutter_gallery/lib/demo/contacts_demo.dart +++ b/examples/flutter_gallery/lib/demo/contacts_demo.dart
@@ -49,10 +49,10 @@ @override Widget build(BuildContext context) { final ThemeData themeData = Theme.of(context); - List<Widget> columnChildren = lines.sublist(0, lines.length - 1).map((String line) => new Text(line)).toList(); + final List<Widget> columnChildren = lines.sublist(0, lines.length - 1).map((String line) => new Text(line)).toList(); columnChildren.add(new Text(lines.last, style: themeData.textTheme.caption)); - List<Widget> rowChildren = <Widget>[ + final List<Widget> rowChildren = <Widget>[ new Expanded( child: new Column( crossAxisAlignment: CrossAxisAlignment.start,
diff --git a/examples/flutter_gallery/lib/demo/material/buttons_demo.dart b/examples/flutter_gallery/lib/demo/material/buttons_demo.dart index 3623c5c..00e7bbb 100644 --- a/examples/flutter_gallery/lib/demo/material/buttons_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/buttons_demo.dart
@@ -49,7 +49,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> { @override Widget build(BuildContext context) { - List<ComponentDemoTabData> demos = <ComponentDemoTabData>[ + final List<ComponentDemoTabData> demos = <ComponentDemoTabData>[ new ComponentDemoTabData( tabName: 'RAISED', description: _raisedText,
diff --git a/examples/flutter_gallery/lib/demo/material/cards_demo.dart b/examples/flutter_gallery/lib/demo/material/cards_demo.dart index cba2d80..72a23a0 100644 --- a/examples/flutter_gallery/lib/demo/material/cards_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/cards_demo.dart
@@ -45,9 +45,9 @@ @override Widget build(BuildContext context) { - ThemeData theme = Theme.of(context); - TextStyle titleStyle = theme.textTheme.headline.copyWith(color: Colors.white); - TextStyle descriptionStyle = theme.textTheme.subhead; + final ThemeData theme = Theme.of(context); + final TextStyle titleStyle = theme.textTheme.headline.copyWith(color: Colors.white); + final TextStyle descriptionStyle = theme.textTheme.subhead; return new SizedBox( height: height,
diff --git a/examples/flutter_gallery/lib/demo/material/chip_demo.dart b/examples/flutter_gallery/lib/demo/material/chip_demo.dart index 11b6e04..838d30b 100644 --- a/examples/flutter_gallery/lib/demo/material/chip_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/chip_demo.dart
@@ -22,7 +22,7 @@ @override Widget build(BuildContext context) { - List<Widget> chips = <Widget>[ + final List<Widget> chips = <Widget>[ new Chip( label: new Text('Apple') ),
diff --git a/examples/flutter_gallery/lib/demo/material/date_and_time_picker_demo.dart b/examples/flutter_gallery/lib/demo/material/date_and_time_picker_demo.dart index 8ec92ad..38a601d 100644 --- a/examples/flutter_gallery/lib/demo/material/date_and_time_picker_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/date_and_time_picker_demo.dart
@@ -61,7 +61,7 @@ final ValueChanged<TimeOfDay> selectTime; Future<Null> _selectDate(BuildContext context) async { - DateTime picked = await showDatePicker( + final DateTime picked = await showDatePicker( context: context, initialDate: selectedDate, firstDate: new DateTime(2015, 8), @@ -72,7 +72,7 @@ } Future<Null> _selectTime(BuildContext context) async { - TimeOfDay picked = await showTimePicker( + final TimeOfDay picked = await showTimePicker( context: context, initialTime: selectedTime );
diff --git a/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart b/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart index cf61413..ada798d 100644 --- a/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart
@@ -185,7 +185,7 @@ ) ); - IconData icon = photo.isFavorite ? Icons.star : Icons.star_border; + final IconData icon = photo.isFavorite ? Icons.star : Icons.star_border; switch(tileStyle) { case GridDemoTileStyle.imageOnly:
diff --git a/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart b/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart index a229f7a..bfc8ba0 100644 --- a/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart
@@ -77,7 +77,7 @@ } void handleUndo(LeaveBehindItem item) { - int insertionIndex = lowerBound(leaveBehindItems, item); + final int insertionIndex = lowerBound(leaveBehindItems, item); setState(() { leaveBehindItems.insert(insertionIndex, item); });
diff --git a/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart b/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart index 4e28e80..fdc4418 100644 --- a/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart
@@ -25,7 +25,7 @@ ]; Future<Null> _handleRefresh() { - Completer<Null> completer = new Completer<Null>(); + final Completer<Null> completer = new Completer<Null>(); new Timer(const Duration(seconds: 3), () { completer.complete(null); }); return completer.future.then((_) { _scaffoldKey.currentState?.showSnackBar(new SnackBar( @@ -63,7 +63,7 @@ padding: const EdgeInsets.all(8.0), itemCount: _items.length, itemBuilder: (BuildContext context, int index) { - String item = _items[index]; + final String item = _items[index]; return new ListItem( isThreeLine: true, leading: new CircleAvatar(child: new Text(item)),
diff --git a/examples/flutter_gallery/lib/demo/material/page_selector_demo.dart b/examples/flutter_gallery/lib/demo/material/page_selector_demo.dart index d4f0dc5..daf23ec 100644 --- a/examples/flutter_gallery/lib/demo/material/page_selector_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/page_selector_demo.dart
@@ -10,7 +10,7 @@ final List<IconData> icons; void _handleArrowButtonPress(BuildContext context, int delta) { - TabController controller = DefaultTabController.of(context); + final TabController controller = DefaultTabController.of(context); if (!controller.indexIsChanging) controller.animateTo(controller.index + delta); }
diff --git a/examples/flutter_gallery/lib/demo/material/progress_indicator_demo.dart b/examples/flutter_gallery/lib/demo/material/progress_indicator_demo.dart index 0385d6a..d514d6d 100644 --- a/examples/flutter_gallery/lib/demo/material/progress_indicator_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/progress_indicator_demo.dart
@@ -62,7 +62,7 @@ } Widget _buildIndicators(BuildContext context, Widget child) { - List<Widget> indicators = <Widget>[ + final List<Widget> indicators = <Widget>[ new SizedBox( width: 200.0, child: new LinearProgressIndicator()
diff --git a/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart b/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart index f0f560c..dd3c794 100644 --- a/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart
@@ -35,7 +35,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> { @override Widget build(BuildContext context) { - List<ComponentDemoTabData> demos = <ComponentDemoTabData>[ + final List<ComponentDemoTabData> demos = <ComponentDemoTabData>[ new ComponentDemoTabData( tabName: "CHECKBOX", description: _checkboxText,
diff --git a/examples/flutter_gallery/lib/demo/material/text_field_demo.dart b/examples/flutter_gallery/lib/demo/material/text_field_demo.dart index d84487f..be0222f 100644 --- a/examples/flutter_gallery/lib/demo/material/text_field_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/text_field_demo.dart
@@ -37,7 +37,7 @@ GlobalKey<FormState> _formKey = new GlobalKey<FormState>(); GlobalKey<FormFieldState<InputValue>> _passwordFieldKey = new GlobalKey<FormFieldState<InputValue>>(); void _handleSubmitted() { - FormState form = _formKey.currentState; + final FormState form = _formKey.currentState; if (!form.validate()) { _autovalidate = true; // Start validating on every change. showInSnackBar('Please fix the errors in red before submitting.'); @@ -51,7 +51,7 @@ _formWasEdited = true; if (value.text.isEmpty) return 'Name is required.'; - RegExp nameExp = new RegExp(r'^[A-za-z ]+$'); + final RegExp nameExp = new RegExp(r'^[A-za-z ]+$'); if (!nameExp.hasMatch(value.text)) return 'Please enter only alphabetical characters.'; return null; @@ -59,7 +59,7 @@ String _validatePhoneNumber(InputValue value) { _formWasEdited = true; - RegExp phoneExp = new RegExp(r'^\d\d\d-\d\d\d\-\d\d\d\d$'); + final RegExp phoneExp = new RegExp(r'^\d\d\d-\d\d\d\-\d\d\d\d$'); if (!phoneExp.hasMatch(value.text)) return '###-###-#### - Please enter a valid phone number.'; return null; @@ -67,7 +67,7 @@ String _validatePassword(InputValue value) { _formWasEdited = true; - FormFieldState<InputValue> passwordField = _passwordFieldKey.currentState; + final FormFieldState<InputValue> passwordField = _passwordFieldKey.currentState; if (passwordField.value == null || passwordField.value.text.isEmpty) return 'Please choose a password.'; if (passwordField.value.text != value.text)
diff --git a/examples/flutter_gallery/lib/demo/pesto_demo.dart b/examples/flutter_gallery/lib/demo/pesto_demo.dart index c035508..76f8960 100644 --- a/examples/flutter_gallery/lib/demo/pesto_demo.dart +++ b/examples/flutter_gallery/lib/demo/pesto_demo.dart
@@ -147,7 +147,7 @@ ), delegate: new SliverChildBuilderDelegate( (BuildContext context, int index) { - Recipe recipe = config.recipes[index]; + final Recipe recipe = config.recipes[index]; return new RecipeCard( recipe: recipe, onTap: () { showRecipePage(context, recipe); },
diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart index 426987e..24abd81 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart
@@ -149,7 +149,7 @@ } void updateOrder({ int quantity, bool inCart }) { - Order newOrder = currentOrder.copyWith(quantity: quantity, inCart: inCart); + final Order newOrder = currentOrder.copyWith(quantity: quantity, inCart: inCart); if (currentOrder != newOrder) { setState(() { config.shoppingCart[newOrder.product] = newOrder;
diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart index c97db5a..44645b5 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart
@@ -41,7 +41,7 @@ int _appBarElevation = 0; bool _handleScrollNotification(ScrollNotification notification) { - int elevation = notification.metrics.extentBefore <= 0.0 ? 0 : 1; + final int elevation = notification.metrics.extentBefore <= 0.0 ? 0 : 1; if (elevation != _appBarElevation) { setState(() { _appBarElevation = elevation;
diff --git a/examples/flutter_gallery/lib/gallery/demo.dart b/examples/flutter_gallery/lib/gallery/demo.dart index 4dc0010..9a05620 100644 --- a/examples/flutter_gallery/lib/gallery/demo.dart +++ b/examples/flutter_gallery/lib/gallery/demo.dart
@@ -24,7 +24,7 @@ bool operator==(Object other) { if (other.runtimeType != runtimeType) return false; - ComponentDemoTabData typedOther = other; + final ComponentDemoTabData typedOther = other; return typedOther.tabName == tabName && typedOther.description == description; } @@ -42,7 +42,7 @@ final String title; void _showExampleCode(BuildContext context) { - String tag = demos[DefaultTabController.of(context).index].exampleCodeTag; + final String tag = demos[DefaultTabController.of(context).index].exampleCodeTag; if (tag != null) { Navigator.push(context, new MaterialPageRoute<FullScreenCodeDialog>( builder: (BuildContext context) => new FullScreenCodeDialog(exampleCodeTag: tag)
diff --git a/examples/flutter_gallery/lib/gallery/syntax_highlighter.dart b/examples/flutter_gallery/lib/gallery/syntax_highlighter.dart index 8304360..a534897 100644 --- a/examples/flutter_gallery/lib/gallery/syntax_highlighter.dart +++ b/examples/flutter_gallery/lib/gallery/syntax_highlighter.dart
@@ -93,7 +93,7 @@ if (_generateSpans()) { // Successfully parsed the code - List<TextSpan> formattedText = <TextSpan>[]; + final List<TextSpan> formattedText = <TextSpan>[]; int currentPosition = 0; for (_HighlightSpan span in _spans) { @@ -134,7 +134,7 @@ // Line comments if (_scanner.scan("//")) { - int startComment = _scanner.lastMatch.start; + final int startComment = _scanner.lastMatch.start; bool eof = false; int endComment; @@ -310,7 +310,7 @@ bool _firstLetterIsUpperCase(String str) { if (str.isNotEmpty) { - String first = str.substring(0, 1); + final String first = str.substring(0, 1); return first == first.toUpperCase(); } return false;
diff --git a/examples/flutter_gallery/lib/gallery/updates.dart b/examples/flutter_gallery/lib/gallery/updates.dart index 050d896..450d382 100644 --- a/examples/flutter_gallery/lib/gallery/updates.dart +++ b/examples/flutter_gallery/lib/gallery/updates.dart
@@ -37,9 +37,9 @@ } _lastUpdateCheck = new DateTime.now(); - String updateUrl = await config.updateUrlFetcher(); + final String updateUrl = await config.updateUrlFetcher(); if (updateUrl != null) { - bool wantsUpdate = await showDialog(context: context, child: _buildDialog()); + final bool wantsUpdate = await showDialog(context: context, child: _buildDialog()); if (wantsUpdate != null && wantsUpdate) UrlLauncher.launch(updateUrl); }
diff --git a/examples/flutter_gallery/test/calculator/smoke_test.dart b/examples/flutter_gallery/test/calculator/smoke_test.dart index c149e51..93ed624 100644 --- a/examples/flutter_gallery/test/calculator/smoke_test.dart +++ b/examples/flutter_gallery/test/calculator/smoke_test.dart
@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { - TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); + final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); if (binding is LiveTestWidgetsFlutterBinding) binding.allowAllFrames = true; @@ -16,10 +16,10 @@ testWidgets('Flutter calculator app smoke test', (WidgetTester tester) async { await tester.pumpWidget(new CalculatorDemo()); - Finder oneButton = find.widgetWithText(InkResponse, '1'); + final Finder oneButton = find.widgetWithText(InkResponse, '1'); expect(oneButton, findsOneWidget); - Finder twoButton = find.widgetWithText(InkResponse, '2'); + final Finder twoButton = find.widgetWithText(InkResponse, '2'); expect(twoButton, findsOneWidget); await tester.tap(oneButton); @@ -28,7 +28,7 @@ await tester.pump(); await tester.pump(const Duration(seconds: 1)); // Wait until it has finished. - Finder display = find.widgetWithText(Expanded, '12'); + final Finder display = find.widgetWithText(Expanded, '12'); expect(display, findsOneWidget); }); }
diff --git a/examples/flutter_gallery/test/example_code_display_test.dart b/examples/flutter_gallery/test/example_code_display_test.dart index dd04f50..178d126 100644 --- a/examples/flutter_gallery/test/example_code_display_test.dart +++ b/examples/flutter_gallery/test/example_code_display_test.dart
@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { - TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); + final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); if (binding is LiveTestWidgetsFlutterBinding) binding.allowAllFrames = true;
diff --git a/examples/flutter_gallery/test/example_code_parser_test.dart b/examples/flutter_gallery/test/example_code_parser_test.dart index 94b1d9c..dfa1864 100644 --- a/examples/flutter_gallery/test/example_code_parser_test.dart +++ b/examples/flutter_gallery/test/example_code_parser_test.dart
@@ -11,12 +11,12 @@ void main() { test('Flutter gallery example code parser test', () async { - TestAssetBundle bundle = new TestAssetBundle(); + final TestAssetBundle bundle = new TestAssetBundle(); - String codeSnippet0 = await getExampleCode('test_0', bundle); + final String codeSnippet0 = await getExampleCode('test_0', bundle); expect(codeSnippet0, 'test 0 0\ntest 0 1'); - String codeSnippet1 = await getExampleCode('test_1', bundle); + final String codeSnippet1 = await getExampleCode('test_1', bundle); expect(codeSnippet1, 'test 1 0\ntest 1 1'); }); }
diff --git a/examples/flutter_gallery/test/pesto_test.dart b/examples/flutter_gallery/test/pesto_test.dart index f3598a1..62d71ad 100644 --- a/examples/flutter_gallery/test/pesto_test.dart +++ b/examples/flutter_gallery/test/pesto_test.dart
@@ -7,7 +7,7 @@ import 'package:flutter_gallery/gallery/app.dart'; void main() { - TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); + final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); if (binding is LiveTestWidgetsFlutterBinding) binding.allowAllFrames = true;
diff --git a/examples/flutter_gallery/test/simple_smoke_test.dart b/examples/flutter_gallery/test/simple_smoke_test.dart index 85f5814..34bde46 100644 --- a/examples/flutter_gallery/test/simple_smoke_test.dart +++ b/examples/flutter_gallery/test/simple_smoke_test.dart
@@ -7,7 +7,7 @@ import 'package:flutter_gallery/main.dart' as flutter_gallery_main; void main() { - TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); + final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); if (binding is LiveTestWidgetsFlutterBinding) binding.allowAllFrames = true; @@ -16,7 +16,7 @@ await tester.pump(); // see https://github.com/flutter/flutter/issues/1865 await tester.pump(); // triggers a frame - Finder finder = find.byWidgetPredicate((Widget widget) { + final Finder finder = find.byWidgetPredicate((Widget widget) { return widget is Tooltip && widget.message == 'Open navigation menu'; }); expect(finder, findsOneWidget);
diff --git a/examples/flutter_gallery/test/smoke_test.dart b/examples/flutter_gallery/test/smoke_test.dart index 75a2201..e1b8913 100644 --- a/examples/flutter_gallery/test/smoke_test.dart +++ b/examples/flutter_gallery/test/smoke_test.dart
@@ -32,16 +32,16 @@ // If you're on line 12, then it has index 11. // If you want 1 line before and 1 line after, then you want lines with index 10, 11, and 12. // That's (lineNumber-1)-margin .. (lineNumber-1)+margin, or lineNumber-(margin+1) .. lineNumber+(margin-1) - int margin = 5; - int firstLine = math.max(0, lineNumber - margin); - int lastLine = math.min(lines.length, lineNumber + margin); + final int margin = 5; + final int firstLine = math.max(0, lineNumber - margin); + final int lastLine = math.min(lines.length, lineNumber + margin); print('$name : $route : line $lineNumber of ${lines.length} : $message; nearby lines were:\n ${lines.sublist(firstLine, lastLine).join("\n ")}'); errors += 1; } void verifyToStringOutput(String name, String route, String testString) { int lineNumber = 0; - List<String> lines = testString.split('\n'); + final List<String> lines = testString.split('\n'); if (!testString.endsWith('\n')) reportToStringError(name, route, lines.length, lines, 'does not end with a line feed'); for (String line in lines) { @@ -103,7 +103,7 @@ await tester.pump(const Duration(milliseconds: 400)); // Go back - Finder backButton = find.byTooltip('Back'); + final Finder backButton = find.byTooltip('Back'); expect(backButton, findsOneWidget); await tester.tap(backButton); await tester.pump(); // Start the pop "back" operation. @@ -125,7 +125,7 @@ expect(find.text(kCaption), findsOneWidget); for (String routeName in routeNames) { - Finder finder = findGalleryItemByRouteName(tester, routeName); + final Finder finder = findGalleryItemByRouteName(tester, routeName); Scrollable.ensureVisible(tester.element(finder), alignment: 0.5); await tester.pump(); await tester.pumpUntilNoTransientCallbacks(); @@ -135,7 +135,7 @@ expect(errors, 0); - Finder navigationMenuButton = find.byTooltip('Open navigation menu'); + final Finder navigationMenuButton = find.byTooltip('Open navigation menu'); expect(navigationMenuButton, findsOneWidget); await tester.tap(navigationMenuButton); await tester.pump(); // Start opening drawer.
diff --git a/examples/flutter_gallery/test/update_test.dart b/examples/flutter_gallery/test/update_test.dart index 5ab567c..f3bab47 100644 --- a/examples/flutter_gallery/test/update_test.dart +++ b/examples/flutter_gallery/test/update_test.dart
@@ -11,7 +11,7 @@ } void main() { - TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); + final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); if (binding is LiveTestWidgetsFlutterBinding) binding.allowAllFrames = true; // Regression test for https://github.com/flutter/flutter/pull/5168 @@ -29,7 +29,7 @@ await tester.pump(); // Launch shrine await tester.pump(const Duration(seconds: 1)); // transition is complete - Finder backButton = find.byTooltip('Back'); + final Finder backButton = find.byTooltip('Back'); expect(backButton, findsOneWidget); await tester.tap(backButton); await tester.pump(); // Start the pop "back" operation.
diff --git a/examples/flutter_gallery/test_driver/memory_nav_test.dart b/examples/flutter_gallery/test_driver/memory_nav_test.dart index 4bd1e37..c61a104 100644 --- a/examples/flutter_gallery/test_driver/memory_nav_test.dart +++ b/examples/flutter_gallery/test_driver/memory_nav_test.dart
@@ -18,9 +18,9 @@ }); test('navigation', () async { - Completer<Null> completer = new Completer<Null>(); + final Completer<Null> completer = new Completer<Null>(); bool scroll = true; - SerializableFinder menuItem = find.text('Text fields'); + final SerializableFinder menuItem = find.text('Text fields'); driver.waitFor(menuItem).then<Null>((Null value) async { scroll = false; await new Future<Null>.delayed(kWaitBetweenActions);
diff --git a/examples/flutter_gallery/test_driver/scroll_perf_test.dart b/examples/flutter_gallery/test_driver/scroll_perf_test.dart index c4bce9f..4208573 100644 --- a/examples/flutter_gallery/test_driver/scroll_perf_test.dart +++ b/examples/flutter_gallery/test_driver/scroll_perf_test.dart
@@ -21,9 +21,9 @@ }); test('measure', () async { - Timeline timeline = await driver.traceAction(() async { + final Timeline timeline = await driver.traceAction(() async { // Find the scrollable stock list - SerializableFinder stockList = find.byValueKey('Gallery List'); + final SerializableFinder stockList = find.byValueKey('Gallery List'); expect(stockList, isNotNull); await driver.tap(find.text('Demos'));
diff --git a/examples/flutter_gallery/test_driver/transitions_perf_test.dart b/examples/flutter_gallery/test_driver/transitions_perf_test.dart index 62929e7..24021ad 100644 --- a/examples/flutter_gallery/test_driver/transitions_perf_test.dart +++ b/examples/flutter_gallery/test_driver/transitions_perf_test.dart
@@ -91,7 +91,7 @@ // Verify that the durations data is valid. if (durations.keys.isEmpty) throw 'no "Start Transition" timeline events found'; - Map<String, int> unexpectedValueCounts = <String, int>{}; + final Map<String, int> unexpectedValueCounts = <String, int>{}; durations.forEach((String routeName, List<int> values) { if (values.length != 2) { unexpectedValueCounts[routeName] = values.length; @@ -99,21 +99,21 @@ }); if (unexpectedValueCounts.isNotEmpty) { - StringBuffer error = new StringBuffer('Some routes recorded wrong number of values (expected 2 values/route):\n\n'); + final StringBuffer error = new StringBuffer('Some routes recorded wrong number of values (expected 2 values/route):\n\n'); unexpectedValueCounts.forEach((String routeName, int count) { error.writeln(' - $routeName recorded $count values.'); }); error.writeln('\nFull event sequence:'); - Iterator<Map<String, dynamic>> eventIter = events.iterator; + final Iterator<Map<String, dynamic>> eventIter = events.iterator; String lastEventName = ''; String lastRouteName = ''; while(eventIter.moveNext()) { - String eventName = eventIter.current['name']; + final String eventName = eventIter.current['name']; if (!<String>['Start Transition', 'Frame'].contains(eventName)) continue; - String routeName = eventName == 'Start Transition' + final String routeName = eventName == 'Start Transition' ? eventIter.current['args']['to'] : ''; @@ -147,12 +147,12 @@ }); test('all demos', () async { - Timeline timeline = await driver.traceAction(() async { + final Timeline timeline = await driver.traceAction(() async { // Scroll each demo menu item into view, launch the demo and // return to the demo menu 2x. for(String demoTitle in demoTitles) { print('Testing "$demoTitle" demo'); - SerializableFinder menuItem = find.text(demoTitle); + final SerializableFinder menuItem = find.text(demoTitle); await driver.scrollIntoView(menuItem, alignment: 0.5); await new Future<Null>.delayed(kWaitBetweenActions); @@ -180,9 +180,9 @@ // Save the duration (in microseconds) of the first timeline Frame event // that follows a 'Start Transition' event. The Gallery app adds a // 'Start Transition' event when a demo is launched (see GalleryItem). - TimelineSummary summary = new TimelineSummary.summarize(timeline); + final TimelineSummary summary = new TimelineSummary.summarize(timeline); await summary.writeSummaryToFile('transitions', pretty: true); - String histogramPath = path.join(testOutputsDirectory, 'transition_durations.timeline.json'); + final String histogramPath = path.join(testOutputsDirectory, 'transition_durations.timeline.json'); await saveDurationsHistogram(timeline.json['traceEvents'], histogramPath); }, timeout: const Timeout(const Duration(minutes: 5))); });