diff --git a/examples/stocks/lib/main.dart b/examples/stocks/lib/main.dart index 5e7b238ae5..8b78a60c80 100644 --- a/examples/stocks/lib/main.dart +++ b/examples/stocks/lib/main.dart @@ -80,7 +80,7 @@ class StocksAppState extends State { } Route _getRoute(RouteSettings settings) { - List path = settings.name.split('/'); + final List path = settings.name.split('/'); if (path[0] != '') return null; if (path[1] == 'stock') { @@ -97,7 +97,7 @@ class StocksAppState extends State { } Future _onLocaleChanged(Locale locale) async { - String localeString = locale.toString(); + final String localeString = locale.toString(); await initializeMessages(localeString); Intl.defaultLocale = localeString; return StockStrings.instance; diff --git a/examples/stocks/lib/stock_arrow.dart b/examples/stocks/lib/stock_arrow.dart index cbc91f08c5..e023a78c9e 100644 --- a/examples/stocks/lib/stock_arrow.dart +++ b/examples/stocks/lib/stock_arrow.dart @@ -14,16 +14,16 @@ class StockArrowPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - Paint paint = new Paint()..color = color; + final Paint paint = new Paint()..color = color; paint.strokeWidth = 1.0; const double padding = 2.0; assert(padding > paint.strokeWidth / 2.0); // make sure the circle remains inside the box - double r = (size.shortestSide - padding) / 2.0; // radius of the circle - double centerX = padding + r; - double centerY = padding + r; + final double r = (size.shortestSide - padding) / 2.0; // radius of the circle + final double centerX = padding + r; + final double centerY = padding + r; // Draw the arrow. - double w = 8.0; + final double w = 8.0; double h = 5.0; double arrowY; if (percentChange < 0.0) { @@ -32,7 +32,7 @@ class StockArrowPainter extends CustomPainter { } else { arrowY = centerX - 1.0; } - Path path = new Path(); + final Path path = new Path(); path.moveTo(centerX, arrowY - h); // top of the arrow path.lineTo(centerX + w, arrowY + h); path.lineTo(centerX - w, arrowY + h); @@ -58,8 +58,8 @@ class StockArrow extends StatelessWidget { final double percentChange; int _colorIndexForPercentChange(double percentChange) { - double maxPercent = 10.0; - double normalizedPercentChange = math.min(percentChange.abs(), maxPercent) / maxPercent; + final double maxPercent = 10.0; + final double normalizedPercentChange = math.min(percentChange.abs(), maxPercent) / maxPercent; return 100 + (normalizedPercentChange * 8.0).floor() * 100; } diff --git a/examples/stocks/lib/stock_data.dart b/examples/stocks/lib/stock_data.dart index 231c4ad349..7ab4c6584a 100644 --- a/examples/stocks/lib/stock_data.dart +++ b/examples/stocks/lib/stock_data.dart @@ -44,7 +44,7 @@ class StockData { void appendTo(Map stocks, List symbols) { for (List fields in _data) { - Stock stock = new Stock.fromFields(fields); + final Stock stock = new Stock.fromFields(fields); symbols.add(stock.symbol); stocks[stock.symbol] = stock; } @@ -73,12 +73,12 @@ class StockDataFetcher { if (!actuallyFetchData) return; http.get(_urlToFetch(_nextChunk++)).then((http.Response response) { - String json = response.body; + final String json = response.body; if (json == null) { print("Failed to load stock data chunk ${_nextChunk - 1}"); return null; } - JsonDecoder decoder = const JsonDecoder(); + final JsonDecoder decoder = const JsonDecoder(); callback(new StockData(decoder.convert(json))); if (_nextChunk < _kChunkCount) _fetchNextChunk(); diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index 105b5abccb..8867e27369 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -241,7 +241,7 @@ class StockHomeState extends State { Iterable _filterBySearchQuery(Iterable stocks) { if (_searchQuery.text.isEmpty) return stocks; - RegExp regexp = new RegExp(_searchQuery.text, caseSensitive: false); + final RegExp regexp = new RegExp(_searchQuery.text, caseSensitive: false); return stocks.where((Stock stock) => stock.symbol.contains(regexp)); } diff --git a/examples/stocks/lib/stock_settings.dart b/examples/stocks/lib/stock_settings.dart index 4c09c1ddc7..74841741ee 100644 --- a/examples/stocks/lib/stock_settings.dart +++ b/examples/stocks/lib/stock_settings.dart @@ -102,7 +102,7 @@ class StockSettingsState extends State { } Widget buildSettingsPane(BuildContext context) { - List rows = [ + final List rows = [ new DrawerItem( icon: new Icon(Icons.thumb_up), onPressed: () => _confirmOptimismChange(), diff --git a/examples/stocks/lib/stock_symbol_viewer.dart b/examples/stocks/lib/stock_symbol_viewer.dart index f918530c52..6601d8193b 100644 --- a/examples/stocks/lib/stock_symbol_viewer.dart +++ b/examples/stocks/lib/stock_symbol_viewer.dart @@ -15,12 +15,12 @@ class _StockSymbolView extends StatelessWidget { @override Widget build(BuildContext context) { - String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; + final String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%"; if (stock.percentChange > 0) changeInPrice = "+" + changeInPrice; - TextStyle headings = Theme.of(context).textTheme.body2; + final TextStyle headings = Theme.of(context).textTheme.body2; return new Container( padding: const EdgeInsets.all(20.0), child: new Column( diff --git a/examples/stocks/test/icon_color_test.dart b/examples/stocks/test/icon_color_test.dart index 6d9f312fd3..e014e12b21 100644 --- a/examples/stocks/test/icon_color_test.dart +++ b/examples/stocks/test/icon_color_test.dart @@ -41,10 +41,10 @@ void checkIconColor(WidgetTester tester, String label, Color color) { // The icon is going to be in the same merged semantics box as the text // regardless of how the menu item is represented, so this is a good // way to find the menu item. I hope. - Element semantics = findElementOfExactWidgetTypeGoingUp(tester.element(find.text(label)), MergeSemantics); + final Element semantics = findElementOfExactWidgetTypeGoingUp(tester.element(find.text(label)), MergeSemantics); expect(semantics, isNotNull); - Element asset = findElementOfExactWidgetTypeGoingDown(semantics, RichText); - RichText richText = asset.widget; + final Element asset = findElementOfExactWidgetTypeGoingDown(semantics, RichText); + final RichText richText = asset.widget; expect(richText.text.style.color, equals(color)); } @@ -64,9 +64,9 @@ void main() { expect(find.text('Account Balance'), findsNothing); // drag the drawer out - Point left = new Point(0.0, ui.window.physicalSize.height / 2.0); - Point right = new Point(ui.window.physicalSize.width, left.y); - TestGesture gesture = await tester.startGesture(left); + final Point left = new Point(0.0, ui.window.physicalSize.height / 2.0); + final Point right = new Point(ui.window.physicalSize.width, left.y); + final TestGesture gesture = await tester.startGesture(left); await tester.pump(); await gesture.moveTo(right); await tester.pump(); diff --git a/examples/stocks/test_driver/scroll_perf_test.dart b/examples/stocks/test_driver/scroll_perf_test.dart index 1ea38812df..304549fe82 100644 --- a/examples/stocks/test_driver/scroll_perf_test.dart +++ b/examples/stocks/test_driver/scroll_perf_test.dart @@ -21,9 +21,9 @@ void main() { }); 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('stock-list'); + final SerializableFinder stockList = find.byValueKey('stock-list'); expect(stockList, isNotNull); // Scroll down @@ -39,7 +39,7 @@ void main() { } }); - TimelineSummary summary = new TimelineSummary.summarize(timeline); + final TimelineSummary summary = new TimelineSummary.summarize(timeline); summary.writeSummaryToFile('stocks_scroll_perf', pretty: true); summary.writeTimelineToFile('stocks_scroll_perf', pretty: true); });