From 9541848272396f3ffafad49dd42b32e7c2bf5bc7 Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Fri, 21 Apr 2017 23:09:42 +0200 Subject: [PATCH] make @immutable const classes (#9532) * make @immutable const * fix build --- dev/benchmarks/complex_layout/lib/main.dart | 42 +++++++++---------- dev/manual_tests/drag_and_drop.dart | 4 +- dev/manual_tests/material_arc.dart | 8 ++-- dev/manual_tests/overlay_geometry.dart | 2 +- dev/manual_tests/raw_keyboard.dart | 6 +-- .../lib/demo/animation/home.dart | 2 +- .../lib/demo/animation/widgets.dart | 2 +- .../lib/demo/animation_demo.dart | 4 +- .../lib/demo/calculator/home.dart | 10 ++--- .../lib/demo/calculator_demo.dart | 4 +- .../lib/demo/contacts_demo.dart | 2 +- .../lib/demo/material/buttons_demo.dart | 2 +- .../lib/demo/material/chip_demo.dart | 4 +- .../material/date_and_time_picker_demo.dart | 4 +- .../lib/demo/material/dialog_demo.dart | 2 +- .../demo/material/expansion_panels_demo.dart | 4 +- .../lib/demo/material/grid_list_demo.dart | 6 +-- .../lib/demo/material/leave_behind_demo.dart | 2 +- .../lib/demo/material/list_demo.dart | 2 +- .../lib/demo/material/menu_demo.dart | 2 +- .../lib/demo/material/overscroll_demo.dart | 2 +- .../lib/demo/material/page_selector_demo.dart | 2 +- .../material/selection_controls_demo.dart | 10 ++--- .../lib/demo/material/snack_bar_demo.dart | 2 +- .../lib/demo/material/tabs_demo.dart | 2 +- .../demo/material/text_form_field_demo.dart | 2 +- .../flutter_gallery/lib/demo/pesto_demo.dart | 12 +++--- .../lib/demo/shrine/shrine_home.dart | 10 ++--- examples/flutter_gallery/lib/gallery/app.dart | 2 +- .../flutter_gallery/lib/gallery/demo.dart | 4 +- .../lib/gallery/example_code.dart | 6 +-- .../flutter_gallery/lib/gallery/home.dart | 2 +- .../flutter_gallery/lib/gallery/item.dart | 18 ++++---- examples/flutter_gallery/lib/main.dart | 2 +- .../test/calculator/smoke_test.dart | 2 +- .../test/example_code_display_test.dart | 2 +- examples/flutter_gallery/test/pesto_test.dart | 8 ++-- .../flutter_gallery/test/update_test.dart | 2 +- .../layers/widgets/custom_render_box.dart | 4 +- examples/layers/widgets/media_query.dart | 6 +-- examples/layers/widgets/spinning_mixed.dart | 6 +-- examples/stocks/lib/stock_arrow.dart | 2 +- examples/stocks/lib/stock_home.dart | 2 +- examples/stocks/lib/stock_list.dart | 2 +- examples/stocks/lib/stock_symbol_viewer.dart | 6 +-- .../flutter/lib/src/cupertino/dialog.dart | 6 +-- .../flutter/lib/src/cupertino/slider.dart | 2 +- .../flutter/lib/src/cupertino/switch.dart | 4 +- packages/flutter/lib/src/material/about.dart | 4 +- .../lib/src/material/bottom_sheet.dart | 2 +- packages/flutter/lib/src/material/button.dart | 2 +- .../flutter/lib/src/material/button_bar.dart | 2 +- .../flutter/lib/src/material/checkbox.dart | 2 +- .../lib/src/material/circle_avatar.dart | 2 +- .../flutter/lib/src/material/data_table.dart | 4 +- .../flutter/lib/src/material/date_picker.dart | 2 +- packages/flutter/lib/src/material/dialog.dart | 8 ++-- packages/flutter/lib/src/material/drawer.dart | 2 +- .../flutter/lib/src/material/dropdown.dart | 2 +- .../lib/src/material/flexible_space_bar.dart | 4 +- .../lib/src/material/grid_tile_bar.dart | 2 +- .../flutter/lib/src/material/ink_well.dart | 4 +- .../lib/src/material/input_decorator.dart | 2 +- .../flutter/lib/src/material/material.dart | 2 +- .../lib/src/material/mergeable_material.dart | 4 +- packages/flutter/lib/src/material/page.dart | 4 +- packages/flutter/lib/src/material/radio.dart | 2 +- .../lib/src/material/raised_button.dart | 2 +- .../flutter/lib/src/material/scaffold.dart | 4 +- .../flutter/lib/src/material/scrollbar.dart | 2 +- packages/flutter/lib/src/material/slider.dart | 2 +- .../lib/src/material/tab_controller.dart | 4 +- packages/flutter/lib/src/material/tabs.dart | 4 +- .../flutter/lib/src/material/text_field.dart | 2 +- .../lib/src/material/text_selection.dart | 2 +- .../flutter/lib/src/material/tooltip.dart | 2 +- .../lib/src/material/two_level_list.dart | 2 +- .../lib/src/painting/flutter_logo.dart | 2 +- packages/flutter/lib/src/rendering/box.dart | 2 +- .../lib/src/rendering/sliver_grid.dart | 2 +- .../lib/src/widgets/animated_size.dart | 2 +- packages/flutter/lib/src/widgets/app.dart | 2 +- packages/flutter/lib/src/widgets/async.dart | 2 +- packages/flutter/lib/src/widgets/basic.dart | 2 +- .../flutter/lib/src/widgets/drag_target.dart | 14 +++---- .../lib/src/widgets/editable_text.dart | 2 +- packages/flutter/lib/src/widgets/form.dart | 2 +- .../lib/src/widgets/gesture_detector.dart | 2 +- .../flutter/lib/src/widgets/grid_paper.dart | 2 +- .../lib/src/widgets/modal_barrier.dart | 4 +- .../src/widgets/notification_listener.dart | 2 +- .../lib/src/widgets/performance_overlay.dart | 2 +- .../flutter/lib/src/widgets/placeholder.dart | 2 +- packages/flutter/lib/src/widgets/routes.dart | 2 +- .../widgets/size_changed_layout_notifier.dart | 2 +- packages/flutter/lib/src/widgets/sliver.dart | 15 ++++--- .../src/widgets/sliver_persistent_header.dart | 15 ++++--- .../lib/src/widgets/status_transitions.dart | 7 ++-- packages/flutter/lib/src/widgets/table.dart | 2 +- .../lib/src/widgets/text_selection.dart | 2 +- .../flutter/lib/src/widgets/transitions.dart | 21 +++++----- .../lib/src/widgets/unique_widget.dart | 9 ++-- .../flutter/test/material/about_test.dart | 2 +- .../flutter/test/material/app_bar_test.dart | 2 +- packages/flutter/test/material/app_test.dart | 6 +-- .../test/material/button_bar_test.dart | 2 +- packages/flutter/test/material/chip_test.dart | 2 +- .../test/material/circle_avatar_test.dart | 4 +- .../flutter/test/material/dialog_test.dart | 10 ++--- .../material/flexible_space_bar_test.dart | 4 +- .../flutter/test/material/list_tile_test.dart | 6 +-- .../material/mergeable_material_test.dart | 2 +- .../flutter/test/material/scaffold_test.dart | 2 +- packages/flutter/test/material/tabs_test.dart | 4 +- .../test/material/text_field_test.dart | 16 +++---- .../test/material/time_picker_test.dart | 2 +- .../test/material/two_level_list_test.dart | 2 +- .../user_accounts_drawer_header_test.dart | 8 ++-- .../flutter/test/material/will_pop_test.dart | 4 +- .../test/widgets/animated_size_test.dart | 4 +- packages/flutter/test/widgets/async_test.dart | 2 +- .../test/widgets/build_scope_test.dart | 6 +-- .../test/widgets/dismissible_test.dart | 6 +-- .../widgets/dispose_ancestor_lookup_test.dart | 2 +- .../flutter/test/widgets/draggable_test.dart | 26 ++++++------ packages/flutter/test/widgets/focus_test.dart | 14 +++---- .../flutter/test/widgets/framework_test.dart | 2 +- .../test/widgets/global_keys_moving_test.dart | 4 +- .../flutter/test/widgets/grid_paper_test.dart | 4 +- .../flutter/test/widgets/heroes_test.dart | 10 ++--- .../independent_widget_layout_test.dart | 2 +- .../flutter/test/widgets/inherited_test.dart | 6 +-- .../layout_builder_and_global_keys_test.dart | 4 +- .../layout_builder_and_parent_data_test.dart | 4 +- .../layout_builder_and_state_test.dart | 4 +- .../test/widgets/modal_barrier_test.dart | 6 +-- .../flutter/test/widgets/navigator_test.dart | 6 +-- .../page_forward_transitions_test.dart | 2 +- .../test/widgets/page_transitions_test.dart | 2 +- .../widgets/performance_overlay_test.dart | 2 +- .../remember_scroll_position_test.dart | 6 +-- .../widgets/render_object_widget_test.dart | 2 +- .../widgets/reparent_state_harder_test.dart | 6 +-- .../test/widgets/reparent_state_test.dart | 12 +++--- ...parent_state_with_layout_builder_test.dart | 2 +- .../test/widgets/scroll_behavior_test.dart | 6 +-- ...crollable_custom_scroll_behavior_test.dart | 6 +-- .../test/widgets/scrollable_of_test.dart | 2 +- .../test/widgets/set_state_1_test.dart | 2 +- .../test/widgets/set_state_3_test.dart | 4 +- ...size_changed_layout_notification_test.dart | 4 +- .../widgets/slivers_appbar_floating_test.dart | 6 +-- .../widgets/slivers_appbar_pinned_test.dart | 2 +- .../slivers_appbar_scrolling_test.dart | 8 ++-- .../slivers_block_global_key_test.dart | 2 +- .../test/widgets/slivers_protocol_test.dart | 4 +- .../widgets/stateful_components_test.dart | 4 +- .../test/widgets/status_transitions_test.dart | 2 +- .../flutter/test/widgets/syncing_test.dart | 6 +-- packages/flutter/test/widgets/table_test.dart | 14 +++---- .../flutter/test/widgets/test_widgets.dart | 2 +- .../test/widgets/transitions_test.dart | 20 ++++----- .../test/widgets/unique_widget_test.dart | 2 +- packages/flutter_markdown/example/demo.dart | 2 +- packages/flutter_markdown/lib/src/widget.dart | 11 +++-- .../test/flutter_markdown_test.dart | 20 ++++----- 166 files changed, 397 insertions(+), 403 deletions(-) diff --git a/dev/benchmarks/complex_layout/lib/main.dart b/dev/benchmarks/complex_layout/lib/main.dart index 207f61d24f..00dd1e5a9b 100644 --- a/dev/benchmarks/complex_layout/lib/main.dart +++ b/dev/benchmarks/complex_layout/lib/main.dart @@ -24,7 +24,7 @@ class ComplexLayoutAppState extends State { return new MaterialApp( theme: lightTheme ? new ThemeData.light() : new ThemeData.dark(), title: 'Advanced Layout', - home: new ComplexLayout() + home: const ComplexLayout() ); } @@ -44,7 +44,7 @@ class ComplexLayoutAppState extends State { } class ComplexLayout extends StatefulWidget { - ComplexLayout({ Key key }) : super(key: key); + const ComplexLayout({ Key key }) : super(key: key); @override ComplexLayoutState createState() => new ComplexLayoutState(); @@ -85,7 +85,7 @@ class ComplexLayoutState extends State { new BottomBar(), ], ), - drawer: new GalleryDrawer(), + drawer: const GalleryDrawer(), ); } } @@ -100,9 +100,9 @@ class TopBarMenu extends StatelessWidget { value: 'Friends', child: new MenuItemWithIcon(Icons.people, 'Friends', '5 new') ), - new PopupMenuItem( + const PopupMenuItem( value: 'Events', - child: new MenuItemWithIcon(Icons.event, 'Events', '12 upcoming') + child: const MenuItemWithIcon(Icons.event, 'Events', '12 upcoming') ), new PopupMenuItem( value: 'Events', @@ -120,9 +120,9 @@ class TopBarMenu extends StatelessWidget { value: 'Friends', child: new MenuItemWithIcon(Icons.people, 'Friends', '5') ), - new PopupMenuItem( + const PopupMenuItem( value: 'Events', - child: new MenuItemWithIcon(Icons.event, 'Events', '12') + child: const MenuItemWithIcon(Icons.event, 'Events', '12') ), new PopupMenuItem( value: 'Events', @@ -142,7 +142,7 @@ class TopBarMenu extends StatelessWidget { } class MenuItemWithIcon extends StatelessWidget { - MenuItemWithIcon(this.icon, this.title, this.subtitle); + const MenuItemWithIcon(this.icon, this.title, this.subtitle); final IconData icon; final String title; @@ -164,7 +164,7 @@ class MenuItemWithIcon extends StatelessWidget { } class FancyImageItem extends StatelessWidget { - FancyImageItem(this.index, {Key key}) : super(key: key); + const FancyImageItem(this.index, {Key key}) : super(key: key); final int index; @@ -188,14 +188,14 @@ class FancyImageItem extends StatelessWidget { } class FancyGalleryItem extends StatelessWidget { - FancyGalleryItem(this.index, {Key key}) : super(key: key); + const FancyGalleryItem(this.index, {Key key}) : super(key: key); final int index; @override Widget build(BuildContext context) { return new ListBody( children: [ - new UserHeader('Ali Connors'), + const UserHeader('Ali Connors'), new ItemGalleryBox(index), new InfoBar(), new Padding( @@ -217,7 +217,7 @@ class InfoBar extends StatelessWidget { child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - new MiniIconWithText(Icons.thumb_up, '42'), + const MiniIconWithText(Icons.thumb_up, '42'), new Text('3 Comments', style: Theme.of(context).textTheme.caption) ] ) @@ -233,9 +233,9 @@ class IconBar extends StatelessWidget { child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - new IconWithText(Icons.thumb_up, 'Like'), + const IconWithText(Icons.thumb_up, 'Like'), new IconWithText(Icons.comment, 'Comment'), - new IconWithText(Icons.share, 'Share'), + const IconWithText(Icons.share, 'Share'), ] ) ); @@ -243,7 +243,7 @@ class IconBar extends StatelessWidget { } class IconWithText extends StatelessWidget { - IconWithText(this.icon, this.title); + const IconWithText(this.icon, this.title); final IconData icon; final String title; @@ -264,7 +264,7 @@ class IconWithText extends StatelessWidget { } class MiniIconWithText extends StatelessWidget { - MiniIconWithText(this.icon, this.title); + const MiniIconWithText(this.icon, this.title); final IconData icon; final String title; @@ -305,7 +305,7 @@ class FatDivider extends StatelessWidget { } class UserHeader extends StatelessWidget { - UserHeader(this.userName); + const UserHeader(this.userName); final String userName; @@ -443,7 +443,7 @@ class ItemImageBox extends StatelessWidget { } class ItemGalleryBox extends StatelessWidget { - ItemGalleryBox(this.index); + const ItemGalleryBox(this.index); final int index; @@ -506,7 +506,7 @@ class ItemGalleryBox extends StatelessWidget { ) ), new Container( - child: new TabPageSelector() + child: const TabPageSelector() ) ] ) @@ -542,7 +542,7 @@ class BottomBar extends StatelessWidget { } class BottomBarButton extends StatelessWidget { - BottomBarButton(this.icon, this.title); + const BottomBarButton(this.icon, this.title); final IconData icon; final String title; @@ -565,7 +565,7 @@ class BottomBarButton extends StatelessWidget { } class GalleryDrawer extends StatelessWidget { - GalleryDrawer({ Key key }) : super(key: key); + const GalleryDrawer({ Key key }) : super(key: key); void _changeTheme(BuildContext context, bool value) { ComplexLayoutApp.of(context).lightTheme = value; diff --git a/dev/manual_tests/drag_and_drop.dart b/dev/manual_tests/drag_and_drop.dart index 8bb9950a8d..ebc16b30cf 100644 --- a/dev/manual_tests/drag_and_drop.dart +++ b/dev/manual_tests/drag_and_drop.dart @@ -74,7 +74,7 @@ class DotState extends State { } class ExampleDragSource extends StatelessWidget { - ExampleDragSource({ + const ExampleDragSource({ Key key, this.color, this.heavy: false, @@ -174,7 +174,7 @@ class DashOutlineCirclePainter extends CustomPainter { } class MovableBall extends StatelessWidget { - MovableBall(this.position, this.ballPosition, this.callback); + const MovableBall(this.position, this.ballPosition, this.callback); final int position; final int ballPosition; diff --git a/dev/manual_tests/material_arc.dart b/dev/manual_tests/material_arc.dart index 22e6edae8f..19aa04a2bb 100644 --- a/dev/manual_tests/material_arc.dart +++ b/dev/manual_tests/material_arc.dart @@ -103,7 +103,7 @@ class _PointDemoPainter extends CustomPainter { } class _PointDemo extends StatefulWidget { - _PointDemo({ Key key, this.controller }) : super(key: key); + const _PointDemo({ Key key, this.controller }) : super(key: key); final AnimationController controller; @@ -268,7 +268,7 @@ class _RectangleDemoPainter extends CustomPainter { } class _RectangleDemo extends StatefulWidget { - _RectangleDemo({ Key key, this.controller }) : super(key: key); + const _RectangleDemo({ Key key, this.controller }) : super(key: key); final AnimationController controller; @@ -404,7 +404,7 @@ class _ArcDemo { } class AnimationDemo extends StatefulWidget { - AnimationDemo({ Key key }) : super(key: key); + const AnimationDemo({ Key key }) : super(key: key); @override _AnimationDemoState createState() => new _AnimationDemoState(); @@ -469,6 +469,6 @@ class _AnimationDemoState extends State with TickerProviderStateM void main() { runApp(new MaterialApp( - home: new AnimationDemo() + home: const AnimationDemo() )); } diff --git a/dev/manual_tests/overlay_geometry.dart b/dev/manual_tests/overlay_geometry.dart index 174a92b020..a26a8d0570 100644 --- a/dev/manual_tests/overlay_geometry.dart +++ b/dev/manual_tests/overlay_geometry.dart @@ -57,7 +57,7 @@ class _MarkerPainter extends CustomPainter { } class Marker extends StatelessWidget { - Marker({ + const Marker({ Key key, this.type: MarkerType.touch, this.position, diff --git a/dev/manual_tests/raw_keyboard.dart b/dev/manual_tests/raw_keyboard.dart index 62420c2ab5..1cf154a298 100644 --- a/dev/manual_tests/raw_keyboard.dart +++ b/dev/manual_tests/raw_keyboard.dart @@ -12,15 +12,15 @@ void main() { appBar: new AppBar( title: const Text('Hardware Key Demo'), ), - body: new Center( - child: new RawKeyboardDemo(), + body: const Center( + child: const RawKeyboardDemo(), ), ), )); } class RawKeyboardDemo extends StatefulWidget { - RawKeyboardDemo({ Key key }) : super(key: key); + const RawKeyboardDemo({ Key key }) : super(key: key); @override _HardwareKeyDemoState createState() => new _HardwareKeyDemoState(); diff --git a/examples/flutter_gallery/lib/demo/animation/home.dart b/examples/flutter_gallery/lib/demo/animation/home.dart index 305a242e00..721f7401c8 100644 --- a/examples/flutter_gallery/lib/demo/animation/home.dart +++ b/examples/flutter_gallery/lib/demo/animation/home.dart @@ -366,7 +366,7 @@ class _AllSectionsView extends AnimatedWidget { } class AnimationDemoHome extends StatefulWidget { - AnimationDemoHome({ Key key }) : super(key: key); + const AnimationDemoHome({ Key key }) : super(key: key); static const String routeName = '/animation'; diff --git a/examples/flutter_gallery/lib/demo/animation/widgets.dart b/examples/flutter_gallery/lib/demo/animation/widgets.dart index 9d1cb21b3a..892d88a1b1 100644 --- a/examples/flutter_gallery/lib/demo/animation/widgets.dart +++ b/examples/flutter_gallery/lib/demo/animation/widgets.dart @@ -100,7 +100,7 @@ class SectionTitle extends StatelessWidget { // Small horizontal bar that indicates the selected section. class SectionIndicator extends StatelessWidget { - SectionIndicator({ Key key, this.opacity: 1.0 }) : super(key: key); + const SectionIndicator({ Key key, this.opacity: 1.0 }) : super(key: key); final double opacity; diff --git a/examples/flutter_gallery/lib/demo/animation_demo.dart b/examples/flutter_gallery/lib/demo/animation_demo.dart index 75bbf02715..62e5ef0d61 100644 --- a/examples/flutter_gallery/lib/demo/animation_demo.dart +++ b/examples/flutter_gallery/lib/demo/animation_demo.dart @@ -7,10 +7,10 @@ import 'package:flutter/material.dart'; import 'animation/home.dart'; class AnimationDemo extends StatelessWidget { - AnimationDemo({Key key}) : super(key: key); + const AnimationDemo({Key key}) : super(key: key); static const String routeName = '/animation'; @override - Widget build(BuildContext context) => new AnimationDemoHome(); + Widget build(BuildContext context) => const AnimationDemoHome(); } diff --git a/examples/flutter_gallery/lib/demo/calculator/home.dart b/examples/flutter_gallery/lib/demo/calculator/home.dart index 8df9e8c0f1..6ace8b9648 100644 --- a/examples/flutter_gallery/lib/demo/calculator/home.dart +++ b/examples/flutter_gallery/lib/demo/calculator/home.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; import 'logic.dart'; class Calculator extends StatefulWidget { - Calculator({Key key}) : super(key: key); + const Calculator({Key key}) : super(key: key); @override _CalculatorState createState() => new _CalculatorState(); @@ -138,7 +138,7 @@ class _CalculatorState extends State { } class CalcDisplay extends StatelessWidget { - CalcDisplay({ this.content }); + const CalcDisplay({ this.content }); final String content; @@ -154,7 +154,7 @@ class CalcDisplay extends StatelessWidget { } class KeyPad extends StatelessWidget { - KeyPad({ this.calcState }); + const KeyPad({ this.calcState }); final _CalculatorState calcState; @@ -222,7 +222,7 @@ class KeyPad extends StatelessWidget { } class KeyRow extends StatelessWidget { - KeyRow(this.keys); + const KeyRow(this.keys); final List keys; @@ -238,7 +238,7 @@ class KeyRow extends StatelessWidget { } class CalcKey extends StatelessWidget { - CalcKey(this.text, this.onTap); + const CalcKey(this.text, this.onTap); final String text; final GestureTapCallback onTap; diff --git a/examples/flutter_gallery/lib/demo/calculator_demo.dart b/examples/flutter_gallery/lib/demo/calculator_demo.dart index c76664c180..cc75bc4692 100644 --- a/examples/flutter_gallery/lib/demo/calculator_demo.dart +++ b/examples/flutter_gallery/lib/demo/calculator_demo.dart @@ -7,10 +7,10 @@ import 'package:flutter/material.dart'; import 'calculator/home.dart'; class CalculatorDemo extends StatelessWidget { - CalculatorDemo({Key key}) : super(key: key); + const CalculatorDemo({Key key}) : super(key: key); static const String routeName = '/calculator'; @override - Widget build(BuildContext context) => new Calculator(); + Widget build(BuildContext context) => const Calculator(); } diff --git a/examples/flutter_gallery/lib/demo/contacts_demo.dart b/examples/flutter_gallery/lib/demo/contacts_demo.dart index 6114763b17..fdc55502a3 100644 --- a/examples/flutter_gallery/lib/demo/contacts_demo.dart +++ b/examples/flutter_gallery/lib/demo/contacts_demo.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; class _ContactCategory extends StatelessWidget { - _ContactCategory({ Key key, this.icon, this.children }) : super(key: key); + const _ContactCategory({ Key key, this.icon, this.children }) : super(key: key); final IconData icon; final List children; diff --git a/examples/flutter_gallery/lib/demo/material/buttons_demo.dart b/examples/flutter_gallery/lib/demo/material/buttons_demo.dart index be6c7bc5a1..92fdadc505 100644 --- a/examples/flutter_gallery/lib/demo/material/buttons_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/buttons_demo.dart @@ -100,7 +100,7 @@ class _ButtonsDemoState extends State { // Perform some action }, ), - new RaisedButton( + const RaisedButton( child: const Text('DISABLED'), onPressed: null, ) diff --git a/examples/flutter_gallery/lib/demo/material/chip_demo.dart b/examples/flutter_gallery/lib/demo/material/chip_demo.dart index 0242ea557c..b27de34329 100644 --- a/examples/flutter_gallery/lib/demo/material/chip_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/chip_demo.dart @@ -26,8 +26,8 @@ class _ChipDemoState extends State { const Chip( label: const Text('Apple') ), - new Chip( - avatar: new CircleAvatar(child: const Text('B')), + const Chip( + avatar: const CircleAvatar(child: const Text('B')), label: const Text('Blueberry') ), ]; 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 de847c85b3..7d8587738e 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 @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; class _InputDropdown extends StatelessWidget { - _InputDropdown({ + const _InputDropdown({ Key key, this.child, this.labelText, @@ -47,7 +47,7 @@ class _InputDropdown extends StatelessWidget { } class _DateTimePicker extends StatelessWidget { - _DateTimePicker({ + const _DateTimePicker({ Key key, this.labelText, this.selectedDate, diff --git a/examples/flutter_gallery/lib/demo/material/dialog_demo.dart b/examples/flutter_gallery/lib/demo/material/dialog_demo.dart index a2b17e560b..3cb06fef65 100644 --- a/examples/flutter_gallery/lib/demo/material/dialog_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/dialog_demo.dart @@ -20,7 +20,7 @@ const String _alertWithTitleText = "data to Google, even when no apps are running."; class DialogDemoItem extends StatelessWidget { - DialogDemoItem({ Key key, this.icon, this.color, this.text, this.onPressed }) : super(key: key); + const DialogDemoItem({ Key key, this.icon, this.color, this.text, this.onPressed }) : super(key: key); final IconData icon; final Color color; diff --git a/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart b/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart index 197c3194ac..e08d2da649 100644 --- a/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart @@ -14,7 +14,7 @@ typedef Widget DemoItemBodyBuilder(DemoItem item); typedef String ValueToString(T value); class DualHeaderWithHint extends StatelessWidget { - DualHeaderWithHint({ + const DualHeaderWithHint({ this.name, this.value, this.hint, @@ -76,7 +76,7 @@ class DualHeaderWithHint extends StatelessWidget { } class CollapsibleBody extends StatelessWidget { - CollapsibleBody({ + const CollapsibleBody({ this.margin: EdgeInsets.zero, this.child, this.onSave, 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 f74110567f..87bba38463 100644 --- a/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart @@ -29,7 +29,7 @@ class Photo { } class GridPhotoViewer extends StatefulWidget { - GridPhotoViewer({ Key key, this.photo }) : super(key: key); + const GridPhotoViewer({ Key key, this.photo }) : super(key: key); final Photo photo; @@ -38,7 +38,7 @@ class GridPhotoViewer extends StatefulWidget { } class _GridTitleText extends StatelessWidget { - _GridTitleText(this.text); + const _GridTitleText(this.text); final String text; @@ -227,7 +227,7 @@ class GridDemoPhotoItem extends StatelessWidget { } class GridListDemo extends StatefulWidget { - GridListDemo({ Key key }) : super(key: key); + const GridListDemo({ Key key }) : super(key: key); static const String routeName = '/material/grid-list'; 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 8010f5ecab..d616a06873 100644 --- a/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart @@ -29,7 +29,7 @@ class LeaveBehindItem implements Comparable { } class LeaveBehindDemo extends StatefulWidget { - LeaveBehindDemo({ Key key }) : super(key: key); + const LeaveBehindDemo({ Key key }) : super(key: key); static const String routeName = '/material/leave-behind'; diff --git a/examples/flutter_gallery/lib/demo/material/list_demo.dart b/examples/flutter_gallery/lib/demo/material/list_demo.dart index 17ed02f9cb..14308302bb 100644 --- a/examples/flutter_gallery/lib/demo/material/list_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/list_demo.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; class ListDemo extends StatefulWidget { - ListDemo({ Key key }) : super(key: key); + const ListDemo({ Key key }) : super(key: key); static const String routeName = '/material/list'; diff --git a/examples/flutter_gallery/lib/demo/material/menu_demo.dart b/examples/flutter_gallery/lib/demo/material/menu_demo.dart index d4942abe04..44035fc0f1 100644 --- a/examples/flutter_gallery/lib/demo/material/menu_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/menu_demo.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; class MenuDemo extends StatefulWidget { - MenuDemo({ Key key }) : super(key: key); + const MenuDemo({ Key key }) : super(key: key); static const String routeName = '/material/menu'; diff --git a/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart b/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart index d1cde79a14..d61e78220f 100644 --- a/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart @@ -9,7 +9,7 @@ import 'package:flutter/material.dart'; enum IndicatorType { overscroll, refresh } class OverscrollDemo extends StatefulWidget { - OverscrollDemo({ Key key }) : super(key: key); + const OverscrollDemo({ Key key }) : super(key: key); static const String routeName = '/material/overscroll'; 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 8069541f27..975d5b1cbd 100644 --- a/examples/flutter_gallery/lib/demo/material/page_selector_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/page_selector_demo.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; class _PageSelector extends StatelessWidget { - _PageSelector({ this.icons }); + const _PageSelector({ this.icons }); final List icons; 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 fb0df4fabd..c4a806b3ba 100644 --- a/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart @@ -98,8 +98,8 @@ class _SelectionControlsDemoState extends State { mainAxisSize: MainAxisSize.min, children: [ // Disabled checkboxes - new Checkbox(value: true, onChanged: null), - new Checkbox(value: false, onChanged: null) + const Checkbox(value: true, onChanged: null), + const Checkbox(value: false, onChanged: null) ] ) ] @@ -137,17 +137,17 @@ class _SelectionControlsDemoState extends State { new Row( mainAxisSize: MainAxisSize.min, children: [ - new Radio( + const Radio( value: 0, groupValue: 0, onChanged: null ), - new Radio( + const Radio( value: 1, groupValue: 0, onChanged: null ), - new Radio( + const Radio( value: 2, groupValue: 0, onChanged: null diff --git a/examples/flutter_gallery/lib/demo/material/snack_bar_demo.dart b/examples/flutter_gallery/lib/demo/material/snack_bar_demo.dart index b843b800cc..e2de8792f9 100644 --- a/examples/flutter_gallery/lib/demo/material/snack_bar_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/snack_bar_demo.dart @@ -17,7 +17,7 @@ const String _text3 = "By default snackbars automatically disappear after a few seconds "; class SnackBarDemo extends StatefulWidget { - SnackBarDemo({ Key key }) : super(key: key); + const SnackBarDemo({ Key key }) : super(key: key); static const String routeName = '/material/snack-bar'; diff --git a/examples/flutter_gallery/lib/demo/material/tabs_demo.dart b/examples/flutter_gallery/lib/demo/material/tabs_demo.dart index d93c7cae46..5f2349b423 100644 --- a/examples/flutter_gallery/lib/demo/material/tabs_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/tabs_demo.dart @@ -75,7 +75,7 @@ final Map<_Page, List<_CardData>> _allPages = <_Page, List<_CardData>>{ }; class _CardDataItem extends StatelessWidget { - _CardDataItem({ this.page, this.data }); + const _CardDataItem({ this.page, this.data }); static final double height = 272.0; final _Page page; diff --git a/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart b/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart index bac851a6c6..4f946d8ad3 100644 --- a/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart @@ -7,7 +7,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; class TextFormFieldDemo extends StatefulWidget { - TextFormFieldDemo({ Key key }) : super(key: key); + const TextFormFieldDemo({ Key key }) : super(key: key); static const String routeName = '/material/text-form-field'; diff --git a/examples/flutter_gallery/lib/demo/pesto_demo.dart b/examples/flutter_gallery/lib/demo/pesto_demo.dart index 1ff9058399..ab4d4e39b5 100644 --- a/examples/flutter_gallery/lib/demo/pesto_demo.dart +++ b/examples/flutter_gallery/lib/demo/pesto_demo.dart @@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; class PestoDemo extends StatelessWidget { - PestoDemo({ Key key }) : super(key: key); + const PestoDemo({ Key key }) : super(key: key); static const String routeName = '/pesto'; @@ -31,7 +31,7 @@ final ThemeData _kTheme = new ThemeData( class PestoHome extends StatelessWidget { @override Widget build(BuildContext context) { - return new RecipeGridPage(recipes: kPestoRecipes); + return const RecipeGridPage(recipes: kPestoRecipes); } } @@ -63,7 +63,7 @@ class PestoStyle extends TextStyle { // Displays a grid of recipe cards. class RecipeGridPage extends StatefulWidget { - RecipeGridPage({ Key key, this.recipes }) : super(key: key); + const RecipeGridPage({ Key key, this.recipes }) : super(key: key); final List recipes; @@ -180,7 +180,7 @@ class _RecipeGridPageState extends State { } class PestoLogo extends StatefulWidget { - PestoLogo({this.height, this.t}); + const PestoLogo({this.height, this.t}); final double height; final double t; @@ -239,7 +239,7 @@ class RecipeCard extends StatelessWidget { final TextStyle titleStyle = const PestoStyle(fontSize: 24.0, fontWeight: FontWeight.w600); final TextStyle authorStyle = const PestoStyle(fontWeight: FontWeight.w500, color: Colors.black54); - RecipeCard({ Key key, this.recipe, this.onTap }) : super(key: key); + const RecipeCard({ Key key, this.recipe, this.onTap }) : super(key: key); final Recipe recipe; final VoidCallback onTap; @@ -289,7 +289,7 @@ class RecipeCard extends StatelessWidget { // Displays one recipe. Includes the recipe sheet with a background image. class RecipePage extends StatefulWidget { - RecipePage({ Key key, this.recipe }) : super(key: key); + const RecipePage({ Key key, this.recipe }) : super(key: key); final Recipe recipe; diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart index 5f2b86bc05..c01593dd08 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart @@ -148,9 +148,9 @@ class _VendorItem extends StatelessWidget { // Displays the product's price. If the product is in the shopping cart then the // background is highlighted. abstract class _PriceItem extends StatelessWidget { - _PriceItem({ Key key, @required this.product }) : super(key: key) { - assert(product != null); - } + const _PriceItem({ Key key, @required this.product }) + : assert(product != null), + super(key: key); final Product product; @@ -168,7 +168,7 @@ abstract class _PriceItem extends StatelessWidget { } class _ProductPriceItem extends _PriceItem { - _ProductPriceItem({ Key key, Product product }) : super(key: key, product: product); + const _ProductPriceItem({ Key key, Product product }) : super(key: key, product: product); @override Widget build(BuildContext context) { @@ -181,7 +181,7 @@ class _ProductPriceItem extends _PriceItem { } class _FeaturePriceItem extends _PriceItem { - _FeaturePriceItem({ Key key, Product product }) : super(key: key, product: product); + const _FeaturePriceItem({ Key key, Product product }) : super(key: key, product: product); @override Widget build(BuildContext context) { diff --git a/examples/flutter_gallery/lib/gallery/app.dart b/examples/flutter_gallery/lib/gallery/app.dart index 1985153009..02dad8db42 100644 --- a/examples/flutter_gallery/lib/gallery/app.dart +++ b/examples/flutter_gallery/lib/gallery/app.dart @@ -32,7 +32,7 @@ final ThemeData _kGalleryDarkTheme = new ThemeData( ); class GalleryApp extends StatefulWidget { - GalleryApp({ + const GalleryApp({ this.updateUrlFetcher, this.enablePerformanceOverlay: true, this.checkerboardRasterCacheImages: true, diff --git a/examples/flutter_gallery/lib/gallery/demo.dart b/examples/flutter_gallery/lib/gallery/demo.dart index be4fc4c60a..2b5c028003 100644 --- a/examples/flutter_gallery/lib/gallery/demo.dart +++ b/examples/flutter_gallery/lib/gallery/demo.dart @@ -33,7 +33,7 @@ class ComponentDemoTabData { } class TabbedComponentDemoScaffold extends StatelessWidget { - TabbedComponentDemoScaffold({ + const TabbedComponentDemoScaffold({ this.title, this.demos }); @@ -96,7 +96,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget { } class FullScreenCodeDialog extends StatefulWidget { - FullScreenCodeDialog({ this.exampleCodeTag }); + const FullScreenCodeDialog({ this.exampleCodeTag }); final String exampleCodeTag; diff --git a/examples/flutter_gallery/lib/gallery/example_code.dart b/examples/flutter_gallery/lib/gallery/example_code.dart index f522240180..1070cd4008 100644 --- a/examples/flutter_gallery/lib/gallery/example_code.dart +++ b/examples/flutter_gallery/lib/gallery/example_code.dart @@ -25,7 +25,7 @@ new RaisedButton( // Create a disabled button. // Buttons are disabled when onPressed isn't // specified or is null. -new RaisedButton( +const RaisedButton( child: const Text('BUTTON TITLE'), onPressed: null ); @@ -130,7 +130,7 @@ new Checkbox( // Create a disabled checkbox. // Checkboxes are disabled when onChanged isn't // specified or null. -new Checkbox(value: false, onChanged: null); +const Checkbox(value: false, onChanged: null); // END @@ -167,7 +167,7 @@ new Row( ); // Creates a disabled radio button. -new Radio( +const Radio( value: 0, groupValue: 0, onChanged: null diff --git a/examples/flutter_gallery/lib/gallery/home.dart b/examples/flutter_gallery/lib/gallery/home.dart index 6f28e3bf90..d3590c6aa5 100644 --- a/examples/flutter_gallery/lib/gallery/home.dart +++ b/examples/flutter_gallery/lib/gallery/home.dart @@ -36,7 +36,7 @@ final List<_BackgroundLayer> _kBackgroundLayers = <_BackgroundLayer>[ ]; class _AppBarBackground extends StatelessWidget { - _AppBarBackground({ Key key, this.animation }) : super(key: key); + const _AppBarBackground({ Key key, this.animation }) : super(key: key); final Animation animation; diff --git a/examples/flutter_gallery/lib/gallery/item.dart b/examples/flutter_gallery/lib/gallery/item.dart index 2296831325..aa9b74dd4a 100644 --- a/examples/flutter_gallery/lib/gallery/item.dart +++ b/examples/flutter_gallery/lib/gallery/item.dart @@ -73,7 +73,7 @@ List _buildGalleryItems() { subtitle: 'Section organizer', category: 'Demos', routeName: AnimationDemo.routeName, - buildRoute: (BuildContext context) => new AnimationDemo(), + buildRoute: (BuildContext context) => const AnimationDemo(), ), // Material Components new GalleryItem( @@ -151,7 +151,7 @@ List _buildGalleryItems() { subtitle: 'Row and column layout', category: 'Material Components', routeName: GridListDemo.routeName, - buildRoute: (BuildContext context) => new GridListDemo(), + buildRoute: (BuildContext context) => const GridListDemo(), ), new GalleryItem( title: 'Icons', @@ -165,21 +165,21 @@ List _buildGalleryItems() { subtitle: 'List items with hidden actions', category: 'Material Components', routeName: LeaveBehindDemo.routeName, - buildRoute: (BuildContext context) => new LeaveBehindDemo(), + buildRoute: (BuildContext context) => const LeaveBehindDemo(), ), new GalleryItem( title: 'List', subtitle: 'Layout variations for scrollable lists', category: 'Material Components', routeName: ListDemo.routeName, - buildRoute: (BuildContext context) => new ListDemo(), + buildRoute: (BuildContext context) => const ListDemo(), ), new GalleryItem( title: 'Menus', subtitle: 'Menu buttons and simple menus', category: 'Material Components', routeName: MenuDemo.routeName, - buildRoute: (BuildContext context) => new MenuDemo(), + buildRoute: (BuildContext context) => const MenuDemo(), ), new GalleryItem( title: 'Modal bottom sheet', @@ -214,7 +214,7 @@ List _buildGalleryItems() { subtitle: 'Refresh indicators', category: 'Material Components', routeName: OverscrollDemo.routeName, - buildRoute: (BuildContext context) => new OverscrollDemo(), + buildRoute: (BuildContext context) => const OverscrollDemo(), ), new GalleryItem( title: 'Scrollable tabs', @@ -242,7 +242,7 @@ List _buildGalleryItems() { subtitle: 'Temporary message that appears at the bottom', category: 'Material Components', routeName: SnackBarDemo.routeName, - buildRoute: (BuildContext context) => new SnackBarDemo(), + buildRoute: (BuildContext context) => const SnackBarDemo(), ), new GalleryItem( title: 'Tabs', @@ -256,7 +256,7 @@ List _buildGalleryItems() { subtitle: 'Single line of editable text and numbers', category: 'Material Components', routeName: TextFormFieldDemo.routeName, - buildRoute: (BuildContext context) => new TextFormFieldDemo(), + buildRoute: (BuildContext context) => const TextFormFieldDemo(), ), new GalleryItem( title: 'Tooltips', @@ -327,7 +327,7 @@ List _buildGalleryItems() { subtitle: 'Simple recipe browser', category: 'Demos', routeName: PestoDemo.routeName, - buildRoute: (BuildContext context) => new PestoDemo(), + buildRoute: (BuildContext context) => const PestoDemo(), ), ); return true; diff --git a/examples/flutter_gallery/lib/main.dart b/examples/flutter_gallery/lib/main.dart index 62febc3eba..bd04ff6ecf 100644 --- a/examples/flutter_gallery/lib/main.dart +++ b/examples/flutter_gallery/lib/main.dart @@ -10,5 +10,5 @@ import 'package:flutter/widgets.dart'; import 'gallery/app.dart'; void main() { - runApp(new GalleryApp()); + runApp(const GalleryApp()); } diff --git a/examples/flutter_gallery/test/calculator/smoke_test.dart b/examples/flutter_gallery/test/calculator/smoke_test.dart index 12926177bb..85458e1413 100644 --- a/examples/flutter_gallery/test/calculator/smoke_test.dart +++ b/examples/flutter_gallery/test/calculator/smoke_test.dart @@ -14,7 +14,7 @@ void main() { // We press the "1" and the "2" buttons and check that the display // reads "12". testWidgets('Flutter calculator app smoke test', (WidgetTester tester) async { - await tester.pumpWidget(new CalculatorDemo()); + await tester.pumpWidget(const CalculatorDemo()); final Finder oneButton = find.widgetWithText(InkResponse, '1'); expect(oneButton, findsOneWidget); diff --git a/examples/flutter_gallery/test/example_code_display_test.dart b/examples/flutter_gallery/test/example_code_display_test.dart index 6034f73fff..678dc1aa40 100644 --- a/examples/flutter_gallery/test/example_code_display_test.dart +++ b/examples/flutter_gallery/test/example_code_display_test.dart @@ -14,7 +14,7 @@ void main() { testWidgets('Flutter gallery button example code displays', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/6147 - await tester.pumpWidget(new GalleryApp()); + await tester.pumpWidget(const GalleryApp()); await tester.pump(); // see https://github.com/flutter/flutter/issues/1865 await tester.pump(); // triggers a frame diff --git a/examples/flutter_gallery/test/pesto_test.dart b/examples/flutter_gallery/test/pesto_test.dart index 13257ecab0..9bf2b44a81 100644 --- a/examples/flutter_gallery/test/pesto_test.dart +++ b/examples/flutter_gallery/test/pesto_test.dart @@ -15,11 +15,11 @@ void main() { testWidgets('Pesto appbar heroics', (WidgetTester tester) async { await tester.pumpWidget( // The bug only manifests itself when the screen's orientation is portrait - new Center( - child: new SizedBox( + const Center( + child: const SizedBox( width: 400.0, height: 800.0, - child: new GalleryApp() + child: const GalleryApp() ) ) ); @@ -43,7 +43,7 @@ void main() { }); testWidgets('Pesto can be scrolled all the way down', (WidgetTester tester) async { - await tester.pumpWidget(new GalleryApp()); + await tester.pumpWidget(const GalleryApp()); await tester.pump(); // see https://github.com/flutter/flutter/issues/1865 await tester.tap(find.text('Pesto')); diff --git a/examples/flutter_gallery/test/update_test.dart b/examples/flutter_gallery/test/update_test.dart index 24cbf114db..9d3b1263c1 100644 --- a/examples/flutter_gallery/test/update_test.dart +++ b/examples/flutter_gallery/test/update_test.dart @@ -17,7 +17,7 @@ void main() { // Regression test for https://github.com/flutter/flutter/pull/5168 testWidgets('update dialog', (WidgetTester tester) async { - await tester.pumpWidget(new GalleryApp(updateUrlFetcher: mockUpdateUrlFetcher)); + await tester.pumpWidget(const GalleryApp(updateUrlFetcher: mockUpdateUrlFetcher)); await tester.pump(); // see https://github.com/flutter/flutter/issues/1865 await tester.pump(); // triggers a frame diff --git a/examples/layers/widgets/custom_render_box.dart b/examples/layers/widgets/custom_render_box.dart index ea57436969..6a2b5b4b25 100644 --- a/examples/layers/widgets/custom_render_box.dart +++ b/examples/layers/widgets/custom_render_box.dart @@ -39,12 +39,12 @@ class RenderDots extends RenderConstrainedBox { } class Dots extends SingleChildRenderObjectWidget { - Dots({ Key key, Widget child }) : super(key: key, child: child); + const Dots({ Key key, Widget child }) : super(key: key, child: child); @override RenderDots createRenderObject(BuildContext context) => new RenderDots(); } void main() { - runApp(new Dots(child: const Center(child: const Text('Touch me!')))); + runApp(const Dots(child: const Center(child: const Text('Touch me!')))); } diff --git a/examples/layers/widgets/media_query.dart b/examples/layers/widgets/media_query.dart index 5a638dde7f..d7aec23d46 100644 --- a/examples/layers/widgets/media_query.dart +++ b/examples/layers/widgets/media_query.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; class AdaptedListItem extends StatelessWidget { - AdaptedListItem({ Key key, this.name }) : super(key: key); + const AdaptedListItem({ Key key, this.name }) : super(key: key); final String name; @@ -28,7 +28,7 @@ class AdaptedListItem extends StatelessWidget { } class AdaptedGridItem extends StatelessWidget { - AdaptedGridItem({ Key key, this.name }) : super(key: key); + const AdaptedGridItem({ Key key, this.name }) : super(key: key); final String name; @@ -69,7 +69,7 @@ const double _kMaxTileWidth = 150.0; const double _kGridViewBreakpoint = 450.0; class AdaptiveContainer extends StatelessWidget { - AdaptiveContainer({ Key key, this.names }) : super(key: key); + const AdaptiveContainer({ Key key, this.names }) : super(key: key); final List names; diff --git a/examples/layers/widgets/spinning_mixed.dart b/examples/layers/widgets/spinning_mixed.dart index 0e053f1f05..2a1c06d5f3 100644 --- a/examples/layers/widgets/spinning_mixed.dart +++ b/examples/layers/widgets/spinning_mixed.dart @@ -17,7 +17,7 @@ void addFlexChildSolidColor(RenderFlex parent, Color backgroundColor, { int flex // Solid colour, Widget version class Rectangle extends StatelessWidget { - Rectangle(this.color, { Key key }) : super(key: key); + const Rectangle(this.color, { Key key }) : super(key: key); final Color color; @@ -41,7 +41,7 @@ void attachWidgetTreeToRenderTree(RenderProxyBox container) { height: 300.0, child: new Column( children: [ - new Rectangle(const Color(0xFF00FFFF)), + const Rectangle(const Color(0xFF00FFFF)), new Material( child: new Container( padding: const EdgeInsets.all(10.0), @@ -66,7 +66,7 @@ void attachWidgetTreeToRenderTree(RenderProxyBox container) { ) ) ), - new Rectangle(const Color(0xFFFFFF00)), + const Rectangle(const Color(0xFFFFFF00)), ], mainAxisAlignment: MainAxisAlignment.spaceBetween ) diff --git a/examples/stocks/lib/stock_arrow.dart b/examples/stocks/lib/stock_arrow.dart index b57f93142a..bb6a5a4241 100644 --- a/examples/stocks/lib/stock_arrow.dart +++ b/examples/stocks/lib/stock_arrow.dart @@ -53,7 +53,7 @@ class StockArrowPainter extends CustomPainter { } class StockArrow extends StatelessWidget { - StockArrow({ Key key, this.percentChange }) : super(key: key); + const StockArrow({ Key key, this.percentChange }) : super(key: key); final double percentChange; diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index dc8da524e1..11a87c67fe 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -345,7 +345,7 @@ class _CreateCompanySheet extends StatelessWidget { // TODO(ianh): Fill this out. return new Column( children: [ - new TextField( + const TextField( autofocus: true, decoration: const InputDecoration( hintText: 'Company Name', diff --git a/examples/stocks/lib/stock_list.dart b/examples/stocks/lib/stock_list.dart index c247dfc8ea..e9fc311138 100644 --- a/examples/stocks/lib/stock_list.dart +++ b/examples/stocks/lib/stock_list.dart @@ -8,7 +8,7 @@ import 'stock_data.dart'; import 'stock_row.dart'; class StockList extends StatelessWidget { - StockList({ Key key, this.stocks, this.onOpen, this.onShow, this.onAction }) : super(key: key); + const StockList({ Key key, this.stocks, this.onOpen, this.onShow, this.onAction }) : super(key: key); final List stocks; final StockRowActionCallback onOpen; diff --git a/examples/stocks/lib/stock_symbol_viewer.dart b/examples/stocks/lib/stock_symbol_viewer.dart index 153e9fbf10..6d299196b8 100644 --- a/examples/stocks/lib/stock_symbol_viewer.dart +++ b/examples/stocks/lib/stock_symbol_viewer.dart @@ -8,7 +8,7 @@ import 'stock_arrow.dart'; import 'stock_data.dart'; class _StockSymbolView extends StatelessWidget { - _StockSymbolView({ this.stock, this.arrow }); + const _StockSymbolView({ this.stock, this.arrow }); final Stock stock; final Widget arrow; @@ -63,7 +63,7 @@ class _StockSymbolView extends StatelessWidget { } class StockSymbolPage extends StatelessWidget { - StockSymbolPage({ this.stock }); + const StockSymbolPage({ this.stock }); final Stock stock; @@ -92,7 +92,7 @@ class StockSymbolPage extends StatelessWidget { } class StockSymbolBottomSheet extends StatelessWidget { - StockSymbolBottomSheet({ this.stock }); + const StockSymbolBottomSheet({ this.stock }); final Stock stock; diff --git a/packages/flutter/lib/src/cupertino/dialog.dart b/packages/flutter/lib/src/cupertino/dialog.dart index 238c794529..a6e6851fb9 100644 --- a/packages/flutter/lib/src/cupertino/dialog.dart +++ b/packages/flutter/lib/src/cupertino/dialog.dart @@ -57,7 +57,7 @@ const BoxDecoration _kCupertinoDialogDecoration = const BoxDecoration( /// * class CupertinoDialog extends StatelessWidget { /// Creates an iOS-style dialog. - CupertinoDialog({ + const CupertinoDialog({ Key key, this.child, }) : super(key: key); @@ -94,7 +94,7 @@ class CupertinoDialog extends StatelessWidget { /// * class CupertinoAlertDialog extends StatelessWidget { /// Creates an iOS-style alert dialog. - CupertinoAlertDialog({ + const CupertinoAlertDialog({ Key key, this.title, this.content, @@ -233,7 +233,7 @@ const double _kButtonBarHeight = 45.0; const Color _kButtonDividerColor = const Color(0xFFD5D5D5); class _CupertinoButtonBar extends StatelessWidget { - _CupertinoButtonBar({ + const _CupertinoButtonBar({ Key key, this.children, }) : super(key: key); diff --git a/packages/flutter/lib/src/cupertino/slider.dart b/packages/flutter/lib/src/cupertino/slider.dart index 7a6451dd79..5853ac3dd7 100644 --- a/packages/flutter/lib/src/cupertino/slider.dart +++ b/packages/flutter/lib/src/cupertino/slider.dart @@ -140,7 +140,7 @@ class _CupertinoSliderState extends State with TickerProviderSt } class _CupertinoSliderRenderObjectWidget extends LeafRenderObjectWidget { - _CupertinoSliderRenderObjectWidget({ + const _CupertinoSliderRenderObjectWidget({ Key key, this.value, this.divisions, diff --git a/packages/flutter/lib/src/cupertino/switch.dart b/packages/flutter/lib/src/cupertino/switch.dart index f86437f8da..00fe0b0acd 100644 --- a/packages/flutter/lib/src/cupertino/switch.dart +++ b/packages/flutter/lib/src/cupertino/switch.dart @@ -26,7 +26,7 @@ import 'thumb_painter.dart'; /// * class CupertinoSwitch extends StatefulWidget { /// Creates an iOS-style switch. - CupertinoSwitch({ + const CupertinoSwitch({ Key key, @required this.value, @required this.onChanged, @@ -88,7 +88,7 @@ class _CupertinoSwitchState extends State with TickerProviderSt } class _CupertinoSwitchRenderObjectWidget extends LeafRenderObjectWidget { - _CupertinoSwitchRenderObjectWidget({ + const _CupertinoSwitchRenderObjectWidget({ Key key, this.value, this.activeColor, diff --git a/packages/flutter/lib/src/material/about.dart b/packages/flutter/lib/src/material/about.dart index 9ae8cae693..fba1cabfe4 100644 --- a/packages/flutter/lib/src/material/about.dart +++ b/packages/flutter/lib/src/material/about.dart @@ -39,7 +39,7 @@ class AboutListTile extends StatelessWidget { /// The arguments are all optional. The application name, if omitted, will be /// derived from the nearest [Title] widget. The version, icon, and legalese /// values default to the empty string. - AboutListTile({ + const AboutListTile({ Key key, this.icon: const Icon(null), this.child, @@ -210,7 +210,7 @@ class AboutDialog extends StatelessWidget { /// The arguments are all optional. The application name, if omitted, will be /// derived from the nearest [Title] widget. The version, icon, and legalese /// values default to the empty string. - AboutDialog({ + const AboutDialog({ Key key, this.applicationName, this.applicationVersion, diff --git a/packages/flutter/lib/src/material/bottom_sheet.dart b/packages/flutter/lib/src/material/bottom_sheet.dart index 0f8bfa6d38..d298034c12 100644 --- a/packages/flutter/lib/src/material/bottom_sheet.dart +++ b/packages/flutter/lib/src/material/bottom_sheet.dart @@ -171,7 +171,7 @@ class _ModalBottomSheetLayout extends SingleChildLayoutDelegate { } class _ModalBottomSheet extends StatefulWidget { - _ModalBottomSheet({ Key key, this.route }) : super(key: key); + const _ModalBottomSheet({ Key key, this.route }) : super(key: key); final _ModalBottomSheetRoute route; diff --git a/packages/flutter/lib/src/material/button.dart b/packages/flutter/lib/src/material/button.dart index 7ebcf77bf3..9239897582 100644 --- a/packages/flutter/lib/src/material/button.dart +++ b/packages/flutter/lib/src/material/button.dart @@ -126,7 +126,7 @@ class MaterialButton extends StatefulWidget { /// /// Rather than creating a material button directly, consider using /// [FlatButton] or [RaisedButton]. - MaterialButton({ + const MaterialButton({ Key key, this.colorBrightness, this.textTheme, diff --git a/packages/flutter/lib/src/material/button_bar.dart b/packages/flutter/lib/src/material/button_bar.dart index 7c98e27029..6ba0a3ce43 100644 --- a/packages/flutter/lib/src/material/button_bar.dart +++ b/packages/flutter/lib/src/material/button_bar.dart @@ -27,7 +27,7 @@ class ButtonBar extends StatelessWidget { /// Creates a button bar. /// /// The alignment argument defaults to [MainAxisAlignment.end]. - ButtonBar({ + const ButtonBar({ Key key, this.alignment: MainAxisAlignment.end, this.mainAxisSize: MainAxisSize.max, diff --git a/packages/flutter/lib/src/material/checkbox.dart b/packages/flutter/lib/src/material/checkbox.dart index 502251d5eb..35c719c184 100644 --- a/packages/flutter/lib/src/material/checkbox.dart +++ b/packages/flutter/lib/src/material/checkbox.dart @@ -41,7 +41,7 @@ class Checkbox extends StatefulWidget { /// /// * [value] determines whether the checkbox is checked. /// * [onChanged] is called when the value of the checkbox should change. - Checkbox({ + const Checkbox({ Key key, @required this.value, @required this.onChanged, diff --git a/packages/flutter/lib/src/material/circle_avatar.dart b/packages/flutter/lib/src/material/circle_avatar.dart index dfd1a805ed..fdb0702970 100644 --- a/packages/flutter/lib/src/material/circle_avatar.dart +++ b/packages/flutter/lib/src/material/circle_avatar.dart @@ -44,7 +44,7 @@ import 'typography.dart'; /// * class CircleAvatar extends StatelessWidget { /// Creates a circle that represents a user. - CircleAvatar({ + const CircleAvatar({ Key key, this.child, this.backgroundColor, diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index 40cdad8387..7f31161767 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -607,7 +607,7 @@ class DataTable extends StatelessWidget { /// [Table], and put the other contents of the cell inside it.) class TableRowInkWell extends InkResponse { /// Creates an ink well for a table row. - TableRowInkWell({ + const TableRowInkWell({ Key key, Widget child, GestureTapCallback onTap, @@ -661,7 +661,7 @@ class TableRowInkWell extends InkResponse { } class _SortArrow extends StatefulWidget { - _SortArrow({ + const _SortArrow({ Key key, this.visible, this.down, diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index ab562739d5..73e0150e66 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -573,7 +573,7 @@ class _YearPickerState extends State { } class _DatePickerDialog extends StatefulWidget { - _DatePickerDialog({ + const _DatePickerDialog({ Key key, this.initialDate, this.firstDate, diff --git a/packages/flutter/lib/src/material/dialog.dart b/packages/flutter/lib/src/material/dialog.dart index c8ea8585f2..d7cee7b776 100644 --- a/packages/flutter/lib/src/material/dialog.dart +++ b/packages/flutter/lib/src/material/dialog.dart @@ -31,7 +31,7 @@ class Dialog extends StatelessWidget { /// Creates a dialog. /// /// Typically used in conjunction with [showDialog]. - Dialog({ + const Dialog({ Key key, this.child, }) : super(key: key); @@ -90,7 +90,7 @@ class AlertDialog extends StatelessWidget { /// Creates an alert dialog. /// /// Typically used in conjunction with [showDialog]. - AlertDialog({ + const AlertDialog({ Key key, this.title, this.titlePadding, @@ -194,7 +194,7 @@ class AlertDialog extends StatelessWidget { /// * class SimpleDialogOption extends StatelessWidget { /// Creates an option for a [SimpleDialog]. - SimpleDialogOption({ + const SimpleDialogOption({ Key key, this.onPressed, this.child, @@ -244,7 +244,7 @@ class SimpleDialog extends StatelessWidget { /// Creates a simple dialog. /// /// Typically used in conjunction with [showDialog]. - SimpleDialog({ + const SimpleDialog({ Key key, this.title, this.titlePadding, diff --git a/packages/flutter/lib/src/material/drawer.dart b/packages/flutter/lib/src/material/drawer.dart index a6f625b747..8c96fb3fb4 100644 --- a/packages/flutter/lib/src/material/drawer.dart +++ b/packages/flutter/lib/src/material/drawer.dart @@ -66,7 +66,7 @@ class Drawer extends StatelessWidget { /// Creates a material design drawer. /// /// Typically used in the [Scaffold.drawer] property. - Drawer({ + const Drawer({ Key key, this.elevation: 16, this.child diff --git a/packages/flutter/lib/src/material/dropdown.dart b/packages/flutter/lib/src/material/dropdown.dart index 385958aea5..48f06928b2 100644 --- a/packages/flutter/lib/src/material/dropdown.dart +++ b/packages/flutter/lib/src/material/dropdown.dart @@ -90,7 +90,7 @@ class _DropdownScrollBehavior extends ScrollBehavior { } class _DropdownMenu extends StatefulWidget { - _DropdownMenu({ + const _DropdownMenu({ Key key, this.route, }) : super(key: key); diff --git a/packages/flutter/lib/src/material/flexible_space_bar.dart b/packages/flutter/lib/src/material/flexible_space_bar.dart index d30294e580..9ca9d77412 100644 --- a/packages/flutter/lib/src/material/flexible_space_bar.dart +++ b/packages/flutter/lib/src/material/flexible_space_bar.dart @@ -30,7 +30,7 @@ class FlexibleSpaceBar extends StatefulWidget { /// Creates a flexible space bar. /// /// Most commonly used in the [AppBar.flexibleSpace] field. - FlexibleSpaceBar({ + const FlexibleSpaceBar({ Key key, this.title, this.background, @@ -161,7 +161,7 @@ class _FlexibleSpaceBarState extends State { } class _FlexibleSpaceBarSettings extends InheritedWidget { - _FlexibleSpaceBarSettings({ + const _FlexibleSpaceBarSettings({ Key key, this.toolbarOpacity, this.minExtent, diff --git a/packages/flutter/lib/src/material/grid_tile_bar.dart b/packages/flutter/lib/src/material/grid_tile_bar.dart index b7cb165454..f9c981e93e 100644 --- a/packages/flutter/lib/src/material/grid_tile_bar.dart +++ b/packages/flutter/lib/src/material/grid_tile_bar.dart @@ -24,7 +24,7 @@ class GridTileBar extends StatelessWidget { /// Creates a grid tile bar. /// /// Typically used to with [GridTile]. - GridTileBar({ + const GridTileBar({ Key key, this.backgroundColor, this.leading, diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart index ffe186d2b9..18e06040e1 100644 --- a/packages/flutter/lib/src/material/ink_well.dart +++ b/packages/flutter/lib/src/material/ink_well.dart @@ -31,7 +31,7 @@ class InkResponse extends StatefulWidget { /// Creates an area of a [Material] that responds to touch. /// /// Must have an ancestor [Material] widget in which to cause ink reactions. - InkResponse({ + const InkResponse({ Key key, this.child, this.onTap, @@ -253,7 +253,7 @@ class InkWell extends InkResponse { /// Creates an ink well. /// /// Must have an ancestor [Material] widget in which to cause ink reactions. - InkWell({ + const InkWell({ Key key, Widget child, GestureTapCallback onTap, diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index 33d8664236..5b053cc1c5 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -235,7 +235,7 @@ class InputDecoration { class InputDecorator extends StatelessWidget { /// Creates a widget that displayes labels and other visual elements similar /// to a [TextField]. - InputDecorator({ + const InputDecorator({ Key key, @required this.decoration, this.baseStyle, diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index f888114f01..2c4bb362eb 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -358,7 +358,7 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController } class _InkFeatures extends SingleChildRenderObjectWidget { - _InkFeatures({ Key key, this.color, Widget child, @required this.vsync }) : super(key: key, child: child); + const _InkFeatures({ Key key, this.color, Widget child, @required this.vsync }) : super(key: key, child: child); // This widget must be owned by a MaterialState, which must be provided as the vsync. // This relationship must be 1:1 and cannot change for the lifetime of the MaterialState. diff --git a/packages/flutter/lib/src/material/mergeable_material.dart b/packages/flutter/lib/src/material/mergeable_material.dart index 132ac83806..0394606a3e 100644 --- a/packages/flutter/lib/src/material/mergeable_material.dart +++ b/packages/flutter/lib/src/material/mergeable_material.dart @@ -95,7 +95,7 @@ class MaterialGap extends MergeableMaterialItem { /// but otherwise looks the same. class MergeableMaterial extends StatefulWidget { /// Creates a mergeable Material list of items. - MergeableMaterial({ + const MergeableMaterial({ Key key, this.mainAxis: Axis.vertical, this.elevation: 2, @@ -615,7 +615,7 @@ class _MergeableMaterialState extends State with TickerProvid // The parent hierarchy can change and lead to the slice being // rebuilt. Using a global key solves the issue. class _MergeableMaterialSliceKey extends GlobalKey { - const _MergeableMaterialSliceKey(this.value) : super.constructor(); + _MergeableMaterialSliceKey(this.value) : super.constructor(); final LocalKey value; diff --git a/packages/flutter/lib/src/material/page.dart b/packages/flutter/lib/src/material/page.dart index 17ed23caab..53074174d4 100644 --- a/packages/flutter/lib/src/material/page.dart +++ b/packages/flutter/lib/src/material/page.dart @@ -3,12 +3,12 @@ // found in the LICENSE file. import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'theme.dart'; -// Fractional offset from 1/4 screen below the top to fully on screen. +// Fractional offset from 1/4 screen below the top to fully on screen. final FractionalOffsetTween _kBottomUpTween = new FractionalOffsetTween( begin: FractionalOffset.bottomLeft, end: FractionalOffset.topLeft diff --git a/packages/flutter/lib/src/material/radio.dart b/packages/flutter/lib/src/material/radio.dart index ed20f09e61..ccb636143f 100644 --- a/packages/flutter/lib/src/material/radio.dart +++ b/packages/flutter/lib/src/material/radio.dart @@ -46,7 +46,7 @@ class Radio extends StatefulWidget { /// /// * [value] and [groupValue] together determines whether the radio button is selected. /// * [onChanged] is when the user selects this radio button. - Radio({ + const Radio({ Key key, @required this.value, @required this.groupValue, diff --git a/packages/flutter/lib/src/material/raised_button.dart b/packages/flutter/lib/src/material/raised_button.dart index 8650e05b2e..f7688d3867 100644 --- a/packages/flutter/lib/src/material/raised_button.dart +++ b/packages/flutter/lib/src/material/raised_button.dart @@ -36,7 +36,7 @@ class RaisedButton extends StatelessWidget { /// /// The [child] argument is required and is typically a [Text] widget in all /// caps. - RaisedButton({ + const RaisedButton({ Key key, @required this.onPressed, this.color, diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index 11aa6e9053..885802c9fa 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -141,7 +141,7 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate { } class _FloatingActionButtonTransition extends StatefulWidget { - _FloatingActionButtonTransition({ + const _FloatingActionButtonTransition({ Key key, this.child, }) : super(key: key); @@ -938,7 +938,7 @@ class ScaffoldFeatureController { } class _PersistentBottomSheet extends StatefulWidget { - _PersistentBottomSheet({ + const _PersistentBottomSheet({ Key key, this.animationController, this.onClosing, diff --git a/packages/flutter/lib/src/material/scrollbar.dart b/packages/flutter/lib/src/material/scrollbar.dart index b564dfcfa5..d50df064f1 100644 --- a/packages/flutter/lib/src/material/scrollbar.dart +++ b/packages/flutter/lib/src/material/scrollbar.dart @@ -27,7 +27,7 @@ class Scrollbar extends StatefulWidget { /// /// The [child] should be a source of [ScrollNotification] notifications, /// typically a [Scrollable] widget. - Scrollbar({ + const Scrollbar({ Key key, @required this.child, }) : super(key: key); diff --git a/packages/flutter/lib/src/material/slider.dart b/packages/flutter/lib/src/material/slider.dart index 9f1ed40695..a4cb5d5cf3 100644 --- a/packages/flutter/lib/src/material/slider.dart +++ b/packages/flutter/lib/src/material/slider.dart @@ -177,7 +177,7 @@ class _SliderState extends State with TickerProviderStateMixin { } class _SliderRenderObjectWidget extends LeafRenderObjectWidget { - _SliderRenderObjectWidget({ + const _SliderRenderObjectWidget({ Key key, this.value, this.divisions, diff --git a/packages/flutter/lib/src/material/tab_controller.dart b/packages/flutter/lib/src/material/tab_controller.dart index 1a052593dc..968e973aa2 100644 --- a/packages/flutter/lib/src/material/tab_controller.dart +++ b/packages/flutter/lib/src/material/tab_controller.dart @@ -170,7 +170,7 @@ class TabController extends ChangeNotifier { } class _TabControllerScope extends InheritedWidget { - _TabControllerScope({ + const _TabControllerScope({ Key key, this.controller, this.enabled, @@ -227,7 +227,7 @@ class DefaultTabController extends StatefulWidget { /// The [length] argument must be great than one. /// /// The [initialIndex] argument must not be null. - DefaultTabController({ + const DefaultTabController({ Key key, @required this.length, this.initialIndex: 0, diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index d1b8c14aa6..e4baaaf790 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -103,7 +103,7 @@ class Tab extends StatelessWidget { } class _TabStyle extends AnimatedWidget { - _TabStyle({ + const _TabStyle({ Key key, Animation animation, this.selected, @@ -946,7 +946,7 @@ class TabPageSelectorIndicator extends StatelessWidget { /// ancestor. class TabPageSelector extends StatelessWidget { /// Creates a compact widget that indicates which tab has been selected. - TabPageSelector({ Key key, this.controller }) : super(key: key); + const TabPageSelector({ Key key, this.controller }) : super(key: key); /// This widget's selection and animation state. /// diff --git a/packages/flutter/lib/src/material/text_field.dart b/packages/flutter/lib/src/material/text_field.dart index 3641bb335d..f9a90b1c1d 100644 --- a/packages/flutter/lib/src/material/text_field.dart +++ b/packages/flutter/lib/src/material/text_field.dart @@ -62,7 +62,7 @@ class TextField extends StatefulWidget { /// To remove the decoration entirely (including the extra padding introduced /// by the decoration to save space for the labels), set the [decoration] to /// null. - TextField({ + const TextField({ Key key, this.controller, this.focusNode, diff --git a/packages/flutter/lib/src/material/text_selection.dart b/packages/flutter/lib/src/material/text_selection.dart index e2d680c31c..bed81d5bf5 100644 --- a/packages/flutter/lib/src/material/text_selection.dart +++ b/packages/flutter/lib/src/material/text_selection.dart @@ -17,7 +17,7 @@ const double _kToolbarScreenPadding = 8.0; // pixels /// Manages a copy/paste text selection toolbar. class _TextSelectionToolbar extends StatelessWidget { - _TextSelectionToolbar(this.delegate, {Key key}) : super(key: key); + const _TextSelectionToolbar(this.delegate, {Key key}) : super(key: key); final TextSelectionDelegate delegate; TextEditingValue get value => delegate.textEditingValue; diff --git a/packages/flutter/lib/src/material/tooltip.dart b/packages/flutter/lib/src/material/tooltip.dart index cc593acadd..0778544911 100644 --- a/packages/flutter/lib/src/material/tooltip.dart +++ b/packages/flutter/lib/src/material/tooltip.dart @@ -235,7 +235,7 @@ class _TooltipPositionDelegate extends SingleChildLayoutDelegate { } class _TooltipOverlay extends StatelessWidget { - _TooltipOverlay({ + const _TooltipOverlay({ Key key, this.message, this.height, diff --git a/packages/flutter/lib/src/material/two_level_list.dart b/packages/flutter/lib/src/material/two_level_list.dart index 3dad002491..65d2bb5a6a 100644 --- a/packages/flutter/lib/src/material/two_level_list.dart +++ b/packages/flutter/lib/src/material/two_level_list.dart @@ -104,7 +104,7 @@ class TwoLevelListItem extends StatelessWidget { /// * [ListTile] class TwoLevelSublist extends StatefulWidget { /// Creates an item in a two-level list that can expland and collapse. - TwoLevelSublist({ + const TwoLevelSublist({ Key key, this.leading, @required this.title, diff --git a/packages/flutter/lib/src/painting/flutter_logo.dart b/packages/flutter/lib/src/painting/flutter_logo.dart index 8a548f6ff3..97ba120a0f 100644 --- a/packages/flutter/lib/src/painting/flutter_logo.dart +++ b/packages/flutter/lib/src/painting/flutter_logo.dart @@ -50,7 +50,7 @@ class FlutterLogoDecoration extends Decoration { // (see https://github.com/dart-lang/sdk/issues/26980 for details about that ignore statement) _opacity = 1.0; - FlutterLogoDecoration._(this.lightColor, this.darkColor, this.textColor, this.style, this._position, this._opacity, this.margin); + const FlutterLogoDecoration._(this.lightColor, this.darkColor, this.textColor, this.style, this._position, this._opacity, this.margin); /// The lighter of the two colors used to paint the logo. /// diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart index fb4cdf365a..703276a138 100644 --- a/packages/flutter/lib/src/rendering/box.dart +++ b/packages/flutter/lib/src/rendering/box.dart @@ -532,7 +532,7 @@ enum _IntrinsicDimension { minWidth, maxWidth, minHeight, maxHeight } @immutable class _IntrinsicDimensionsCacheEntry { - _IntrinsicDimensionsCacheEntry(this.dimension, this.argument); + const _IntrinsicDimensionsCacheEntry(this.dimension, this.argument); final _IntrinsicDimension dimension; final double argument; diff --git a/packages/flutter/lib/src/rendering/sliver_grid.dart b/packages/flutter/lib/src/rendering/sliver_grid.dart index e6523099fd..9771b34d4c 100644 --- a/packages/flutter/lib/src/rendering/sliver_grid.dart +++ b/packages/flutter/lib/src/rendering/sliver_grid.dart @@ -145,7 +145,7 @@ class SliverGridRegularTileLayout extends SliverGridLayout { /// /// All of the arguments must not be null and must not be negative. The /// `crossAxisCount` argument must be greater than zero. - SliverGridRegularTileLayout({ + const SliverGridRegularTileLayout({ @required this.crossAxisCount, @required this.mainAxisStride, @required this.crossAxisStride, diff --git a/packages/flutter/lib/src/widgets/animated_size.dart b/packages/flutter/lib/src/widgets/animated_size.dart index d2ec413bcc..d9070e3a5a 100644 --- a/packages/flutter/lib/src/widgets/animated_size.dart +++ b/packages/flutter/lib/src/widgets/animated_size.dart @@ -15,7 +15,7 @@ class AnimatedSize extends SingleChildRenderObjectWidget { /// Creates a widget that animates its size to match that of its child. /// /// The [curve] and [duration] arguments must not be null. - AnimatedSize({ + const AnimatedSize({ Key key, Widget child, this.alignment: FractionalOffset.center, diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index 6bf4178f6e..415b4ce784 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -223,7 +223,7 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv performanceOverlay = new PerformanceOverlay.allEnabled( checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages); } else if (widget.checkerboardRasterCacheImages) { - performanceOverlay = new PerformanceOverlay(checkerboardRasterCacheImages: true); + performanceOverlay = const PerformanceOverlay(checkerboardRasterCacheImages: true); } if (performanceOverlay != null) { diff --git a/packages/flutter/lib/src/widgets/async.dart b/packages/flutter/lib/src/widgets/async.dart index 64bf31e1c8..3e3121a01b 100644 --- a/packages/flutter/lib/src/widgets/async.dart +++ b/packages/flutter/lib/src/widgets/async.dart @@ -43,7 +43,7 @@ import 'package:meta/meta.dart' show required; /// recent interaction is needed for widget building. abstract class StreamBuilderBase extends StatefulWidget { /// Creates a [StreamBuilderBase] connected to the specified [stream]. - StreamBuilderBase({ Key key, this.stream }) : super(key: key); + const StreamBuilderBase({ Key key, this.stream }) : super(key: key); /// The asynchronous computation to which this builder is currently connected, /// possibly null. When changed, the current summary is updated using diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 005f8ff08e..069f457138 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -1787,7 +1787,7 @@ class Positioned extends ParentDataWidget { /// Creates a Positioned object with [left], [top], [right], and [bottom] set /// to 0.0 unless a value for them is passed. - Positioned.fill({ + const Positioned.fill({ Key key, this.left: 0.0, this.top: 0.0, diff --git a/packages/flutter/lib/src/widgets/drag_target.dart b/packages/flutter/lib/src/widgets/drag_target.dart index 0895e3d77c..288252265a 100644 --- a/packages/flutter/lib/src/widgets/drag_target.dart +++ b/packages/flutter/lib/src/widgets/drag_target.dart @@ -83,7 +83,7 @@ class Draggable extends StatefulWidget { /// /// The [child] and [feedback] arguments must not be null. If /// [maxSimultaneousDrags] is non-null, it must be non-negative. - Draggable({ + const Draggable({ Key key, @required this.child, @required this.feedback, @@ -95,11 +95,11 @@ class Draggable extends StatefulWidget { this.maxSimultaneousDrags, this.onDragStarted, this.onDraggableCanceled - }) : super(key: key) { - assert(child != null); - assert(feedback != null); - assert(maxSimultaneousDrags == null || maxSimultaneousDrags >= 0); - } + }) : assert(child != null), + assert(feedback != null), + assert(maxSimultaneousDrags == null || maxSimultaneousDrags >= 0), + super(key: key); + /// The data that will be dropped by this draggable. final T data; @@ -207,7 +207,7 @@ class LongPressDraggable extends Draggable { /// /// The [child] and [feedback] arguments must not be null. If /// [maxSimultaneousDrags] is non-null, it must be non-negative. - LongPressDraggable({ + const LongPressDraggable({ Key key, @required Widget child, @required Widget feedback, diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index d8800709b1..e59d3a018e 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -487,7 +487,7 @@ class EditableTextState extends State implements TextInputClient { } class _Editable extends LeafRenderObjectWidget { - _Editable({ + const _Editable({ Key key, this.value, this.style, diff --git a/packages/flutter/lib/src/widgets/form.dart b/packages/flutter/lib/src/widgets/form.dart index 589e2769e3..b0c18337ba 100644 --- a/packages/flutter/lib/src/widgets/form.dart +++ b/packages/flutter/lib/src/widgets/form.dart @@ -132,7 +132,7 @@ class FormState extends State
{ } class _FormScope extends InheritedWidget { - _FormScope({ + const _FormScope({ Key key, Widget child, FormState formState, diff --git a/packages/flutter/lib/src/widgets/gesture_detector.dart b/packages/flutter/lib/src/widgets/gesture_detector.dart index 03b60f8f27..6193216db8 100644 --- a/packages/flutter/lib/src/widgets/gesture_detector.dart +++ b/packages/flutter/lib/src/widgets/gesture_detector.dart @@ -475,7 +475,7 @@ class RawGestureDetectorState extends State { } class _GestureSemantics extends SingleChildRenderObjectWidget { - _GestureSemantics({ + const _GestureSemantics({ Key key, Widget child, this.owner diff --git a/packages/flutter/lib/src/widgets/grid_paper.dart b/packages/flutter/lib/src/widgets/grid_paper.dart index ea7a9f4096..1d8fd0da40 100644 --- a/packages/flutter/lib/src/widgets/grid_paper.dart +++ b/packages/flutter/lib/src/widgets/grid_paper.dart @@ -52,7 +52,7 @@ class _GridPaperPainter extends CustomPainter { /// Useful with a [Stack] for visualizing your layout along a grid. class GridPaper extends StatelessWidget { /// Creates a widget that draws a rectilinear grid of 1px wide lines. - GridPaper({ + const GridPaper({ Key key, this.color: const Color(0x7FC3E8F3), this.interval: 100.0, diff --git a/packages/flutter/lib/src/widgets/modal_barrier.dart b/packages/flutter/lib/src/widgets/modal_barrier.dart index 2246b8ee1b..d61d43b522 100644 --- a/packages/flutter/lib/src/widgets/modal_barrier.dart +++ b/packages/flutter/lib/src/widgets/modal_barrier.dart @@ -12,7 +12,7 @@ import 'transitions.dart'; /// A widget that prevents the user from interacting with widgets behind itself. class ModalBarrier extends StatelessWidget { /// Creates a widget that blocks user interaction. - ModalBarrier({ + const ModalBarrier({ Key key, this.color, this.dismissible: true @@ -50,7 +50,7 @@ class ModalBarrier extends StatelessWidget { /// A widget that prevents the user from interacting with widgets behind itself. class AnimatedModalBarrier extends AnimatedWidget { /// Creates a widget that blocks user interaction. - AnimatedModalBarrier({ + const AnimatedModalBarrier({ Key key, Animation color, this.dismissible: true diff --git a/packages/flutter/lib/src/widgets/notification_listener.dart b/packages/flutter/lib/src/widgets/notification_listener.dart index 7dbf82dd6b..8704865adf 100644 --- a/packages/flutter/lib/src/widgets/notification_listener.dart +++ b/packages/flutter/lib/src/widgets/notification_listener.dart @@ -86,7 +86,7 @@ abstract class Notification { /// To dispatch notifications, use the [Notification.dispatch] method. class NotificationListener extends StatelessWidget { /// Creates a widget that listens for notifications. - NotificationListener({ + const NotificationListener({ Key key, @required this.child, this.onNotification diff --git a/packages/flutter/lib/src/widgets/performance_overlay.dart b/packages/flutter/lib/src/widgets/performance_overlay.dart index df2175642e..081ea19fba 100644 --- a/packages/flutter/lib/src/widgets/performance_overlay.dart +++ b/packages/flutter/lib/src/widgets/performance_overlay.dart @@ -27,7 +27,7 @@ class PerformanceOverlay extends LeafRenderObjectWidget { /// Create a performance overlay that only displays specific statistics. The /// mask is created by shifting 1 by the index of the specific /// [StatisticOption] to enable. - PerformanceOverlay({ + const PerformanceOverlay({ Key key, this.optionsMask: 0, this.rasterizerThreshold: 0, diff --git a/packages/flutter/lib/src/widgets/placeholder.dart b/packages/flutter/lib/src/widgets/placeholder.dart index 3fc2667275..6f6bf8a5ee 100644 --- a/packages/flutter/lib/src/widgets/placeholder.dart +++ b/packages/flutter/lib/src/widgets/placeholder.dart @@ -8,7 +8,7 @@ import 'framework.dart'; /// A widget whose child can be mutated. class Placeholder extends StatefulWidget { /// Creates a widget whose child can be mutated. - Placeholder({ Key key }) : super(key: key); + const Placeholder({ Key key }) : super(key: key); @override PlaceholderState createState() => new PlaceholderState(); diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index 684056d353..14d6f4df20 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -416,7 +416,7 @@ enum RoutePopDisposition { typedef Future WillPopCallback(); class _ModalScope extends StatefulWidget { - _ModalScope({ + const _ModalScope({ Key key, this.route, @required this.page, diff --git a/packages/flutter/lib/src/widgets/size_changed_layout_notifier.dart b/packages/flutter/lib/src/widgets/size_changed_layout_notifier.dart index 1a8dfbe902..a3d09ac0e9 100644 --- a/packages/flutter/lib/src/widgets/size_changed_layout_notifier.dart +++ b/packages/flutter/lib/src/widgets/size_changed_layout_notifier.dart @@ -39,7 +39,7 @@ class SizeChangedLayoutNotification extends LayoutChangedNotification { } class SizeChangedLayoutNotifier extends SingleChildRenderObjectWidget { /// Creates a [SizeChangedLayoutNotifier] that dispatches layout changed /// notifications when [child] changes layout size. - SizeChangedLayoutNotifier({ + const SizeChangedLayoutNotifier({ Key key, Widget child }) : super(key: key, child: child); diff --git a/packages/flutter/lib/src/widgets/sliver.dart b/packages/flutter/lib/src/widgets/sliver.dart index 628dc190d7..40b7f31c4e 100644 --- a/packages/flutter/lib/src/widgets/sliver.dart +++ b/packages/flutter/lib/src/widgets/sliver.dart @@ -230,12 +230,11 @@ class SliverChildListDelegate extends SliverChildDelegate { /// Helps subclasses build their children lazily using a [SliverChildDelegate]. abstract class SliverMultiBoxAdaptorWidget extends RenderObjectWidget { /// Initializes fields for subclasses. - SliverMultiBoxAdaptorWidget({ + const SliverMultiBoxAdaptorWidget({ Key key, @required this.delegate, - }) : super(key: key) { - assert(delegate != null); - } + }) : assert(delegate != null), + super(key: key); /// The delegate that provides the children for this widget. /// @@ -308,7 +307,7 @@ abstract class SliverMultiBoxAdaptorWidget extends RenderObjectWidget { /// * [SliverGrid], which places its children in arbitrary positions. class SliverList extends SliverMultiBoxAdaptorWidget { /// Creates a sliver that places box children in a linear array. - SliverList({ + const SliverList({ Key key, @required SliverChildDelegate delegate, }) : super(key: key, delegate: delegate); @@ -341,7 +340,7 @@ class SliverList extends SliverMultiBoxAdaptorWidget { class SliverFixedExtentList extends SliverMultiBoxAdaptorWidget { /// Creates a sliver that places box children with the same main axis extent /// in a linear array. - SliverFixedExtentList({ + const SliverFixedExtentList({ Key key, @required SliverChildDelegate delegate, @required this.itemExtent, @@ -376,7 +375,7 @@ class SliverFixedExtentList extends SliverMultiBoxAdaptorWidget { class SliverGrid extends SliverMultiBoxAdaptorWidget { /// Creates a sliver that places multiple box children in a two dimensional /// arrangement. - SliverGrid({ + const SliverGrid({ Key key, @required SliverChildDelegate delegate, @required this.gridDelegate, @@ -694,7 +693,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render /// * [SliverList], which shows a list of variable-sized children in a /// viewport. class SliverFillRemaining extends SingleChildRenderObjectWidget { - SliverFillRemaining({ + const SliverFillRemaining({ Key key, Widget child, }) : super(key: key, child: child); diff --git a/packages/flutter/lib/src/widgets/sliver_persistent_header.dart b/packages/flutter/lib/src/widgets/sliver_persistent_header.dart index fe9346cedc..d466be142b 100644 --- a/packages/flutter/lib/src/widgets/sliver_persistent_header.dart +++ b/packages/flutter/lib/src/widgets/sliver_persistent_header.dart @@ -146,12 +146,11 @@ class _SliverPersistentHeaderElement extends RenderObjectElement { } abstract class _SliverPersistentHeaderRenderObjectWidget extends RenderObjectWidget { - _SliverPersistentHeaderRenderObjectWidget({ + const _SliverPersistentHeaderRenderObjectWidget({ Key key, @required this.delegate, - }) : super(key: key) { - assert(delegate != null); - } + }) : assert(delegate != null), + super(key: key); final SliverPersistentHeaderDelegate delegate; @@ -190,7 +189,7 @@ abstract class _RenderSliverPersistentHeaderForWidgetsMixin implements RenderSli } class _SliverScrollingPersistentHeader extends _SliverPersistentHeaderRenderObjectWidget { - _SliverScrollingPersistentHeader({ + const _SliverScrollingPersistentHeader({ Key key, @required SliverPersistentHeaderDelegate delegate, }) : super(key: key, delegate: delegate); @@ -208,7 +207,7 @@ class _RenderSliverScrollingPersistentHeaderForWidgets extends _RenderSliverScro with _RenderSliverPersistentHeaderForWidgetsMixin { } class _SliverPinnedPersistentHeader extends _SliverPersistentHeaderRenderObjectWidget { - _SliverPinnedPersistentHeader({ + const _SliverPinnedPersistentHeader({ Key key, @required SliverPersistentHeaderDelegate delegate, }) : super(key: key, delegate: delegate); @@ -225,7 +224,7 @@ abstract class _RenderSliverPinnedPersistentHeader extends RenderSliverPinnedPer class _RenderSliverPinnedPersistentHeaderForWidgets extends _RenderSliverPinnedPersistentHeader with _RenderSliverPersistentHeaderForWidgetsMixin { } class _SliverFloatingPersistentHeader extends _SliverPersistentHeaderRenderObjectWidget { - _SliverFloatingPersistentHeader({ + const _SliverFloatingPersistentHeader({ Key key, @required SliverPersistentHeaderDelegate delegate, }) : super(key: key, delegate: delegate); @@ -250,7 +249,7 @@ abstract class _RenderSliverFloatingPinnedPersistentHeader extends RenderSliverF class _RenderSliverFloatingPinnedPersistentHeaderForWidgets extends _RenderSliverFloatingPinnedPersistentHeader with _RenderSliverPersistentHeaderForWidgetsMixin { } class _SliverFloatingPinnedPersistentHeader extends _SliverPersistentHeaderRenderObjectWidget { - _SliverFloatingPinnedPersistentHeader({ + const _SliverFloatingPinnedPersistentHeader({ Key key, @required SliverPersistentHeaderDelegate delegate, }) : super(key: key, delegate: delegate); diff --git a/packages/flutter/lib/src/widgets/status_transitions.dart b/packages/flutter/lib/src/widgets/status_transitions.dart index 6b6fc6c2e7..6daed1b2b9 100644 --- a/packages/flutter/lib/src/widgets/status_transitions.dart +++ b/packages/flutter/lib/src/widgets/status_transitions.dart @@ -12,12 +12,11 @@ abstract class StatusTransitionWidget extends StatefulWidget { /// Initializes fields for subclasses. /// /// The [animation] argument must not be null. - StatusTransitionWidget({ + const StatusTransitionWidget({ Key key, @required this.animation - }) : super(key: key) { - assert(animation != null); - } + }) : assert(animation != null), + super(key: key); /// The animation to which this widget is listening. final Animation animation; diff --git a/packages/flutter/lib/src/widgets/table.dart b/packages/flutter/lib/src/widgets/table.dart index 505b91b503..badd984aa7 100644 --- a/packages/flutter/lib/src/widgets/table.dart +++ b/packages/flutter/lib/src/widgets/table.dart @@ -355,7 +355,7 @@ class _TableElement extends RenderObjectElement { /// other kinds of widgets, like [RenderObjectWidget]s). class TableCell extends ParentDataWidget { /// Creates a widget that controls how a child of a [Table] is aligned. - TableCell({ + const TableCell({ Key key, this.verticalAlignment, @required Widget child diff --git a/packages/flutter/lib/src/widgets/text_selection.dart b/packages/flutter/lib/src/widgets/text_selection.dart index 4376cca574..d487d28e26 100644 --- a/packages/flutter/lib/src/widgets/text_selection.dart +++ b/packages/flutter/lib/src/widgets/text_selection.dart @@ -296,7 +296,7 @@ class TextSelectionOverlay implements TextSelectionDelegate { /// This widget represents a single draggable text selection handle. class _TextSelectionHandleOverlay extends StatefulWidget { - _TextSelectionHandleOverlay({ + const _TextSelectionHandleOverlay({ Key key, this.selection, this.position, diff --git a/packages/flutter/lib/src/widgets/transitions.dart b/packages/flutter/lib/src/widgets/transitions.dart index 34f33599f4..e9e0d30f09 100644 --- a/packages/flutter/lib/src/widgets/transitions.dart +++ b/packages/flutter/lib/src/widgets/transitions.dart @@ -37,12 +37,11 @@ abstract class AnimatedWidget extends StatefulWidget { /// Creates a widget that rebuilds when the given listenable changes. /// /// The [listenable] argument is required. - AnimatedWidget({ + const AnimatedWidget({ Key key, @required this.listenable - }) : super(key: key) { - assert(listenable != null); - } + }) : assert(listenable != null), + super(key: key); /// The [Listenable] to which this widget is listening. /// @@ -102,7 +101,7 @@ class SlideTransition extends AnimatedWidget { /// Creates a fractional translation transition. /// /// The [position] argument must not be null. - SlideTransition({ + const SlideTransition({ Key key, @required Animation position, this.transformHitTests: true, @@ -142,7 +141,7 @@ class ScaleTransition extends AnimatedWidget { /// /// The [scale] argument must not be null. The [alignment] argument defaults /// to [FractionalOffset.center]. - ScaleTransition({ + const ScaleTransition({ Key key, @required Animation scale, this.alignment: FractionalOffset.center, @@ -183,7 +182,7 @@ class RotationTransition extends AnimatedWidget { /// Creates a rotation transition. /// /// The [turns] argument must not be null. - RotationTransition({ + const RotationTransition({ Key key, @required Animation turns, this.child, @@ -270,7 +269,7 @@ class FadeTransition extends AnimatedWidget { /// Creates an opacity transition. /// /// The [opacity] argument must not be null. - FadeTransition({ + const FadeTransition({ Key key, @required Animation opacity, this.child, @@ -322,7 +321,7 @@ class PositionedTransition extends AnimatedWidget { /// Creates a transition for [Positioned]. /// /// The [rect] argument must not be null. - PositionedTransition({ + const PositionedTransition({ Key key, @required Animation rect, @required this.child, @@ -358,7 +357,7 @@ class RelativePositionedTransition extends AnimatedWidget { /// Each frame, the [Positioned] widget will be configured to represent the /// current value of the [rect] argument assuming that the stack has the given /// [size]. Both [rect] and [size] must not be null. - RelativePositionedTransition({ + const RelativePositionedTransition({ Key key, @required Animation rect, @required this.size, @@ -407,7 +406,7 @@ class DecoratedBoxTransition extends AnimatedWidget { /// See also: /// /// * [new DecoratedBox]. - DecoratedBoxTransition({ + const DecoratedBoxTransition({ Key key, @required this.decoration, this.position: DecorationPosition.background, diff --git a/packages/flutter/lib/src/widgets/unique_widget.dart b/packages/flutter/lib/src/widgets/unique_widget.dart index db2cfec96c..606b7c9006 100644 --- a/packages/flutter/lib/src/widgets/unique_widget.dart +++ b/packages/flutter/lib/src/widgets/unique_widget.dart @@ -24,11 +24,10 @@ abstract class UniqueWidget> extends StatefulWid /// /// The [key] argument cannot be null because it identifies the unique /// inflated instance of this widget. - UniqueWidget({ - @required GlobalKey key - }) : super(key: key) { - assert(key != null); - } + const UniqueWidget({ + @required GlobalKey key, + }) : assert(key != null), + super(key: key); @override T createState(); diff --git a/packages/flutter/test/material/about_test.dart b/packages/flutter/test/material/about_test.dart index 233353f7bb..e955a8bbe4 100644 --- a/packages/flutter/test/material/about_test.dart +++ b/packages/flutter/test/material/about_test.dart @@ -67,7 +67,7 @@ void main() { testWidgets('About box logic defaults to executable name for app name', (WidgetTester tester) async { await tester.pumpWidget( - new Material(child: new AboutListTile()), + new Material(child: const AboutListTile()), ); expect(find.text('About flutter_tester'), findsOneWidget); }); diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index 75f8af577d..e8e7aba6a6 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -136,7 +136,7 @@ void main() { title: const Text('X'), ), // A drawer causes a leading hamburger. - drawer: new Drawer(), + drawer: const Drawer(), ), ), ); diff --git a/packages/flutter/test/material/app_test.dart b/packages/flutter/test/material/app_test.dart index ebd9875517..e9b2662214 100644 --- a/packages/flutter/test/material/app_test.dart +++ b/packages/flutter/test/material/app_test.dart @@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/material.dart'; class StateMarker extends StatefulWidget { - StateMarker({ Key key, this.child }) : super(key: key); + const StateMarker({ Key key, this.child }) : super(key: key); final Widget child; @@ -68,7 +68,7 @@ void main() { testWidgets('Can show grid without losing sync', (WidgetTester tester) async { await tester.pumpWidget( new MaterialApp( - home: new StateMarker(), + home: const StateMarker(), ), ); @@ -78,7 +78,7 @@ void main() { await tester.pumpWidget( new MaterialApp( debugShowMaterialGrid: true, - home: new StateMarker(), + home: const StateMarker(), ), ); diff --git a/packages/flutter/test/material/button_bar_test.dart b/packages/flutter/test/material/button_bar_test.dart index 479ee2d55d..37d9339279 100644 --- a/packages/flutter/test/material/button_bar_test.dart +++ b/packages/flutter/test/material/button_bar_test.dart @@ -7,6 +7,6 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('ButtonBar default control', (WidgetTester tester) async { - await tester.pumpWidget(new Center(child: new ButtonBar())); + await tester.pumpWidget(const Center(child: const ButtonBar())); }); } diff --git a/packages/flutter/test/material/chip_test.dart b/packages/flutter/test/material/chip_test.dart index 1461f73842..402c86afc9 100644 --- a/packages/flutter/test/material/chip_test.dart +++ b/packages/flutter/test/material/chip_test.dart @@ -13,7 +13,7 @@ void main() { home: new Material( child: new Center( child: new Chip( - avatar: new CircleAvatar( + avatar: const CircleAvatar( child: const Text('C') ), label: const Text('Chip'), diff --git a/packages/flutter/test/material/circle_avatar_test.dart b/packages/flutter/test/material/circle_avatar_test.dart index 6ff3bd6e57..6878d602ec 100644 --- a/packages/flutter/test/material/circle_avatar_test.dart +++ b/packages/flutter/test/material/circle_avatar_test.dart @@ -62,8 +62,8 @@ void main() { await tester.pumpWidget( new Theme( data: theme, - child: new Center( - child: new CircleAvatar( + child: const Center( + child: const CircleAvatar( child: const Text('Z'), ), ), diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart index 23a66f2d86..b50cc36cd9 100644 --- a/packages/flutter/test/material/dialog_test.dart +++ b/packages/flutter/test/material/dialog_test.dart @@ -101,8 +101,8 @@ void main() { await tester.pumpWidget( new MaterialApp( home: new Material( - child: new Center( - child: new RaisedButton( + child: const Center( + child: const RaisedButton( onPressed: null, child: const Text('Go'), ), @@ -124,7 +124,7 @@ void main() { }, child: const Text('First option'), ), - new SimpleDialogOption( + const SimpleDialogOption( child: const Text('Second option'), ), ], @@ -142,8 +142,8 @@ void main() { await tester.pumpWidget( new MaterialApp( home: new Material( - child: new Center( - child: new RaisedButton( + child: const Center( + child: const RaisedButton( onPressed: null, child: const Text('Go'), ), diff --git a/packages/flutter/test/material/flexible_space_bar_test.dart b/packages/flutter/test/material/flexible_space_bar_test.dart index 7b6595fc52..cfb7fa3b9f 100644 --- a/packages/flutter/test/material/flexible_space_bar_test.dart +++ b/packages/flutter/test/material/flexible_space_bar_test.dart @@ -12,7 +12,7 @@ void main() { theme: new ThemeData(platform: TargetPlatform.android), home: new Scaffold( appBar: new AppBar( - flexibleSpace: new FlexibleSpaceBar( + flexibleSpace: const FlexibleSpaceBar( title: const Text('X') ) ) @@ -33,7 +33,7 @@ void main() { theme: new ThemeData(platform: TargetPlatform.iOS), home: new Scaffold( appBar: new AppBar( - flexibleSpace: new FlexibleSpaceBar( + flexibleSpace: const FlexibleSpaceBar( title: const Text('X') ) ) diff --git a/packages/flutter/test/material/list_tile_test.dart b/packages/flutter/test/material/list_tile_test.dart index 3ea3c752f7..8db2bf47d4 100644 --- a/packages/flutter/test/material/list_tile_test.dart +++ b/packages/flutter/test/material/list_tile_test.dart @@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; class TestIcon extends StatefulWidget { - TestIcon({ Key key }) : super(key: key); + const TestIcon({ Key key }) : super(key: key); @override TestIconState createState() => new TestIconState(); @@ -23,7 +23,7 @@ class TestIconState extends State { } class TestText extends StatefulWidget { - TestText(this.text, { Key key }) : super(key: key); + const TestText(this.text, { Key key }) : super(key: key); final String text; @@ -175,7 +175,7 @@ void main() { return new ListTile( enabled: enabled, selected: selected, - leading: new TestIcon(), + leading: const TestIcon(), title: new TestText('title', key: titleKey), subtitle: new TestText('subtitle', key: subtitleKey), ); diff --git a/packages/flutter/test/material/mergeable_material_test.dart b/packages/flutter/test/material/mergeable_material_test.dart index 53dc149d84..a9aa4d3e83 100644 --- a/packages/flutter/test/material/mergeable_material_test.dart +++ b/packages/flutter/test/material/mergeable_material_test.dart @@ -66,7 +66,7 @@ void main() { await tester.pumpWidget( new Scaffold( body: new SingleChildScrollView( - child: new MergeableMaterial() + child: const MergeableMaterial() ) ) ); diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index f1394d9dc6..92f4e235f7 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -141,7 +141,7 @@ void main() { pinned: true, expandedHeight: appBarHeight, title: const Text('Title'), - flexibleSpace: new FlexibleSpaceBar(title: const Text('Title')), + flexibleSpace: const FlexibleSpaceBar(title: const Text('Title')), ), new SliverPadding( padding: const EdgeInsets.only(top: appBarHeight), diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index d09ce967c5..9961768f2c 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -9,7 +9,7 @@ import 'package:flutter/widgets.dart'; import '../rendering/recording_canvas.dart'; class StateMarker extends StatefulWidget { - StateMarker({ Key key, this.child }) : super(key: key); + const StateMarker({ Key key, this.child }) : super(key: key); final Widget child; @@ -52,7 +52,7 @@ Widget buildFrame({ typedef Widget TabControllerFrameBuilder(BuildContext context, TabController controller); class TabControllerFrame extends StatefulWidget { - TabControllerFrame({ this.length, this.initialIndex: 0, this.builder }); + const TabControllerFrame({ this.length, this.initialIndex: 0, this.builder }); final int length; final int initialIndex; diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 1fcbb4586a..c15ad7a489 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -127,7 +127,7 @@ void main() { Widget builder() { return new Center( child: new Material( - child: new TextField( + child: const TextField( decoration: const InputDecoration( hintText: 'Placeholder', ), @@ -171,7 +171,7 @@ void main() { Widget builder() { return new Center( child: new Material( - child: new TextField( + child: const TextField( obscureText: true, decoration: const InputDecoration( hintText: 'Placeholder', @@ -771,7 +771,7 @@ void main() { child: new Material( child: new Column( children: [ - new TextField( + const TextField( decoration: const InputDecoration( labelText: 'First', ), @@ -813,7 +813,7 @@ void main() { await tester.pumpWidget( new Center( child: new Material( - child: new TextField( + child: const TextField( decoration: const InputDecoration( icon: const Icon(Icons.phone), labelText: 'label', @@ -832,7 +832,7 @@ void main() { await tester.pumpWidget( overlay(new Center( child: new Material( - child: new TextField( + child: const TextField( decoration: const InputDecoration.collapsed( hintText: 'hint', ), @@ -850,7 +850,7 @@ void main() { child: new Material( child: new Container( width: 300.0, - child: new TextField( + child: const TextField( textAlign: TextAlign.center, decoration: null, ), @@ -882,8 +882,8 @@ void main() { child: new Material( child: new Container( width: 300.0, - child: new Center( - child: new TextField( + child: const Center( + child: const TextField( textAlign: TextAlign.center, decoration: null, ), diff --git a/packages/flutter/test/material/time_picker_test.dart b/packages/flutter/test/material/time_picker_test.dart index 1d60422437..90bde69f1f 100644 --- a/packages/flutter/test/material/time_picker_test.dart +++ b/packages/flutter/test/material/time_picker_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; class _TimePickerLauncher extends StatelessWidget { - _TimePickerLauncher({ Key key, this.onChanged }) : super(key: key); + const _TimePickerLauncher({ Key key, this.onChanged }) : super(key: key); final ValueChanged onChanged; diff --git a/packages/flutter/test/material/two_level_list_test.dart b/packages/flutter/test/material/two_level_list_test.dart index a9b8fb420b..db29877f80 100644 --- a/packages/flutter/test/material/two_level_list_test.dart +++ b/packages/flutter/test/material/two_level_list_test.dart @@ -15,7 +15,7 @@ void main() { child: new Center( child: new TwoLevelList( children: [ - new TwoLevelSublist( + const TwoLevelSublist( title: const Text('Title'), ) ] diff --git a/packages/flutter/test/material/user_accounts_drawer_header_test.dart b/packages/flutter/test/material/user_accounts_drawer_header_test.dart index bb5b5d2719..6dc560eae5 100644 --- a/packages/flutter/test/material/user_accounts_drawer_header_test.dart +++ b/packages/flutter/test/material/user_accounts_drawer_header_test.dart @@ -21,7 +21,7 @@ void main() { child: const Text('A'), ), otherAccountsPictures: [ - new CircleAvatar( + const CircleAvatar( child: const Text('B'), ), new CircleAvatar( @@ -32,7 +32,7 @@ void main() { key: avatarD, child: const Text('D'), ), - new CircleAvatar( + const CircleAvatar( child: const Text('E'), ) ], @@ -148,12 +148,12 @@ void main() { ); await tester.pumpWidget(buildFrame( - currentAccountPicture: new CircleAvatar(child: const Text('A')), + currentAccountPicture: const CircleAvatar(child: const Text('A')), )); expect(find.text('A'), findsOneWidget); await tester.pumpWidget(buildFrame( - otherAccountsPictures: [new CircleAvatar(child: const Text('A'))], + otherAccountsPictures: [const CircleAvatar(child: const Text('A'))], )); expect(find.text('A'), findsOneWidget); diff --git a/packages/flutter/test/material/will_pop_test.dart b/packages/flutter/test/material/will_pop_test.dart index 27dd45b03d..ea7c7c4670 100644 --- a/packages/flutter/test/material/will_pop_test.dart +++ b/packages/flutter/test/material/will_pop_test.dart @@ -42,7 +42,7 @@ class SamplePageState extends State { int willPopCount = 0; class SampleForm extends StatelessWidget { - SampleForm({ Key key, this.callback }) : super(key: key); + const SampleForm({ Key key, this.callback }) : super(key: key); final WillPopCallback callback; @@ -56,7 +56,7 @@ class SampleForm extends StatelessWidget { willPopCount += 1; return callback(); }, - child: new TextField(), + child: const TextField(), ), ), ); diff --git a/packages/flutter/test/widgets/animated_size_test.dart b/packages/flutter/test/widgets/animated_size_test.dart index 960cd8c813..2c0b8609f6 100644 --- a/packages/flutter/test/widgets/animated_size_test.dart +++ b/packages/flutter/test/widgets/animated_size_test.dart @@ -179,8 +179,8 @@ void main() { testWidgets('AnimatedSize resync', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new AnimatedSize( + const Center( + child: const AnimatedSize( duration: const Duration(milliseconds: 200), vsync: const TestVSync(), child: const SizedBox( diff --git a/packages/flutter/test/widgets/async_test.dart b/packages/flutter/test/widgets/async_test.dart index 0221a52e79..e87df07dc9 100644 --- a/packages/flutter/test/widgets/async_test.dart +++ b/packages/flutter/test/widgets/async_test.dart @@ -259,7 +259,7 @@ Future eventFiring(WidgetTester tester) async { } class StringCollector extends StreamBuilderBase> { - StringCollector({ Key key, Stream stream }) : super(key: key, stream: stream); + const StringCollector({ Key key, Stream stream }) : super(key: key, stream: stream); @override List initial() => []; diff --git a/packages/flutter/test/widgets/build_scope_test.dart b/packages/flutter/test/widgets/build_scope_test.dart index deb862c7a3..1d506f7912 100644 --- a/packages/flutter/test/widgets/build_scope_test.dart +++ b/packages/flutter/test/widgets/build_scope_test.dart @@ -36,7 +36,7 @@ class ProbeWidgetState extends State { } class BadWidget extends StatelessWidget { - BadWidget(this.parentState); + const BadWidget(this.parentState); final BadWidgetParentState parentState; @@ -85,7 +85,7 @@ class BadDisposeWidgetState extends State { } class StatefulWrapper extends StatefulWidget { - StatefulWrapper({ + const StatefulWrapper({ Key key, this.child, }) : super(key: key); @@ -116,7 +116,7 @@ class StatefulWrapperState extends State { } class Wrapper extends StatelessWidget { - Wrapper({ + const Wrapper({ Key key, this.child, }) : super(key: key); diff --git a/packages/flutter/test/widgets/dismissible_test.dart b/packages/flutter/test/widgets/dismissible_test.dart index 3ef7f532f6..539db7f2d0 100644 --- a/packages/flutter/test/widgets/dismissible_test.dart +++ b/packages/flutter/test/widgets/dismissible_test.dart @@ -112,7 +112,7 @@ Future dismissItem(WidgetTester tester, int item, { DismissDirection gestu } class Test1215DismissibleWidget extends StatelessWidget { - Test1215DismissibleWidget(this.text); + const Test1215DismissibleWidget(this.text); final String text; @@ -290,8 +290,8 @@ void main() { height: 1000.0, child: new Column( children: [ - new Test1215DismissibleWidget('1'), - new Test1215DismissibleWidget('2'), + const Test1215DismissibleWidget('1'), + const Test1215DismissibleWidget('2'), ], ), ), diff --git a/packages/flutter/test/widgets/dispose_ancestor_lookup_test.dart b/packages/flutter/test/widgets/dispose_ancestor_lookup_test.dart index f0ece4bff6..08f4a97ebc 100644 --- a/packages/flutter/test/widgets/dispose_ancestor_lookup_test.dart +++ b/packages/flutter/test/widgets/dispose_ancestor_lookup_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart'; typedef void TestCallback(BuildContext context); class TestWidget extends StatefulWidget { - TestWidget(this.callback); + const TestWidget(this.callback); final TestCallback callback; diff --git a/packages/flutter/test/widgets/draggable_test.dart b/packages/flutter/test/widgets/draggable_test.dart index 6b44ee8462..0b3e0ba716 100644 --- a/packages/flutter/test/widgets/draggable_test.dart +++ b/packages/flutter/test/widgets/draggable_test.dart @@ -74,7 +74,7 @@ void main() { await tester.pumpWidget(new MaterialApp( home: new Column( children: [ - new Draggable( + const Draggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging') @@ -218,7 +218,7 @@ void main() { await tester.pumpWidget(new MaterialApp( home: new Column( children: [ - new LongPressDraggable( + const LongPressDraggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging') @@ -264,7 +264,7 @@ void main() { await tester.pumpWidget(new MaterialApp( home: new Column( children: [ - new Draggable( + const Draggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging') @@ -321,13 +321,13 @@ void main() { } ), new Container(height: 400.0), - new Draggable( + const Draggable( data: 1, child: const Text('H'), feedback: const Text('Dragging'), affinity: Axis.horizontal, ), - new Draggable( + const Draggable( data: 2, child: const Text('V'), feedback: const Text('Dragging'), @@ -428,13 +428,13 @@ void main() { } ), new Container(width: 400.0), - new Draggable( + const Draggable( data: 1, child: const Text('H'), feedback: const Text('Dragging'), affinity: Axis.horizontal, ), - new Draggable( + const Draggable( data: 2, child: const Text('V'), feedback: const Text('Dragging'), @@ -706,12 +706,12 @@ void main() { await tester.pumpWidget(new MaterialApp( home: new Column( children: [ - new Draggable( + const Draggable( data: 1, child: const Text('IntSource'), feedback: const Text('IntDragging') ), - new Draggable( + const Draggable( data: 1.0, child: const Text('DoubleSource'), feedback: const Text('DoubleDragging') @@ -1059,7 +1059,7 @@ void main() { await tester.pumpWidget(new MaterialApp( home: new Column( children: [ - new Draggable( + const Draggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging') @@ -1097,7 +1097,7 @@ void main() { await tester.pumpWidget(new MaterialApp( home: new Column( children: [ - new Draggable( + const Draggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging') @@ -1117,7 +1117,7 @@ void main() { await tester.pumpWidget(new MaterialApp( home: new Column( children: [ - new Draggable( + const Draggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging') @@ -1192,7 +1192,7 @@ void main() { onTap: () { events.add('tap'); }, - child: new LongPressDraggable( + child: const LongPressDraggable( feedback: const Text('Feedback'), child: const Text('X'), ), diff --git a/packages/flutter/test/widgets/focus_test.dart b/packages/flutter/test/widgets/focus_test.dart index 272a126bb2..a80a519dec 100644 --- a/packages/flutter/test/widgets/focus_test.dart +++ b/packages/flutter/test/widgets/focus_test.dart @@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; class TestFocusable extends StatefulWidget { - TestFocusable({ + const TestFocusable({ Key key, this.no, this.yes, @@ -59,11 +59,11 @@ void main() { await tester.pumpWidget( new Column( children: [ - new TestFocusable( + const TestFocusable( no: 'a', yes: 'A FOCUSED', ), - new TestFocusable( + const TestFocusable( no: 'b', yes: 'B FOCUSED', ), @@ -110,7 +110,7 @@ void main() { testWidgets('Can blur', (WidgetTester tester) async { await tester.pumpWidget( - new TestFocusable( + const TestFocusable( no: 'a', yes: 'A FOCUSED', autofocus: false, @@ -146,7 +146,7 @@ void main() { autofocus: true, child: new Row( children: [ - new TestFocusable( + const TestFocusable( no: 'a', yes: 'A FOCUSED', autofocus: false, @@ -175,7 +175,7 @@ void main() { node: parentFocusScope, child: new Row( children: [ - new TestFocusable( + const TestFocusable( no: 'a', yes: 'A FOCUSED', autofocus: false, @@ -200,7 +200,7 @@ void main() { node: parentFocusScope, child: new Row( children: [ - new TestFocusable( + const TestFocusable( no: 'a', yes: 'A FOCUSED', autofocus: false, diff --git a/packages/flutter/test/widgets/framework_test.dart b/packages/flutter/test/widgets/framework_test.dart index a1028c6093..a1d7d7d117 100644 --- a/packages/flutter/test/widgets/framework_test.dart +++ b/packages/flutter/test/widgets/framework_test.dart @@ -440,7 +440,7 @@ void main() { final GlobalKey key = new GlobalKey(); await tester.pumpWidget(new Container(key: key)); expect(log, isEmpty); - await tester.pumpWidget(new Placeholder()); + await tester.pumpWidget(const Placeholder()); debugPrint = oldCallback; debugPrintGlobalKeyedWidgetLifecycle = false; diff --git a/packages/flutter/test/widgets/global_keys_moving_test.dart b/packages/flutter/test/widgets/global_keys_moving_test.dart index b5ad55f9fe..2e7346e09a 100644 --- a/packages/flutter/test/widgets/global_keys_moving_test.dart +++ b/packages/flutter/test/widgets/global_keys_moving_test.dart @@ -15,7 +15,7 @@ class Item { List items = [new Item(), new Item()]; class StatefulLeaf extends StatefulWidget { - StatefulLeaf({ GlobalKey key }) : super(key: key); + const StatefulLeaf({ GlobalKey key }) : super(key: key); @override StatefulLeafState createState() => new StatefulLeafState(); @@ -29,7 +29,7 @@ class StatefulLeafState extends State { } class KeyedWrapper extends StatelessWidget { - KeyedWrapper(this.key1, this.key2); + const KeyedWrapper(this.key1, this.key2); final Key key1; final Key key2; diff --git a/packages/flutter/test/widgets/grid_paper_test.dart b/packages/flutter/test/widgets/grid_paper_test.dart index 3fb55c93fa..4eb4d6dfdd 100644 --- a/packages/flutter/test/widgets/grid_paper_test.dart +++ b/packages/flutter/test/widgets/grid_paper_test.dart @@ -8,9 +8,9 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('GridPaper control test', (WidgetTester tester) async { - await tester.pumpWidget(new GridPaper()); + await tester.pumpWidget(const GridPaper()); final List layers1 = tester.layers; - await tester.pumpWidget(new GridPaper()); + await tester.pumpWidget(const GridPaper()); final List layers2 = tester.layers; expect(layers1, equals(layers2)); }); diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index 7ccdc601da..40ba033010 100644 --- a/packages/flutter/test/widgets/heroes_test.dart +++ b/packages/flutter/test/widgets/heroes_test.dart @@ -77,7 +77,7 @@ class MutatingRoute extends MaterialPageRoute { } class MyStatefulWidget extends StatefulWidget { - MyStatefulWidget({ Key key, this.value: '123' }) : super(key: key); + const MyStatefulWidget({ Key key, this.value: '123' }) : super(key: key); final String value; @override MyStatefulWidgetState createState() => new MyStatefulWidgetState(); @@ -932,9 +932,9 @@ void main() { new Card( child: new Hero( tag: 'H', - child: new SizedBox( + child: const SizedBox( height: 200.0, - child: new MyStatefulWidget(value: '456'), + child: const MyStatefulWidget(value: '456'), ), ), ), @@ -958,9 +958,9 @@ void main() { new Card( child: new Hero( tag: 'H', - child: new SizedBox( + child: const SizedBox( height: 100.0, - child: new MyStatefulWidget(value: '456'), + child: const MyStatefulWidget(value: '456'), ), ), ), diff --git a/packages/flutter/test/widgets/independent_widget_layout_test.dart b/packages/flutter/test/widgets/independent_widget_layout_test.dart index 9e31a30059..5ae15a1127 100644 --- a/packages/flutter/test/widgets/independent_widget_layout_test.dart +++ b/packages/flutter/test/widgets/independent_widget_layout_test.dart @@ -62,7 +62,7 @@ class Trigger { } class TriggerableWidget extends StatefulWidget { - TriggerableWidget({ this.trigger, this.counter }); + const TriggerableWidget({ this.trigger, this.counter }); final Trigger trigger; final Counter counter; @override diff --git a/packages/flutter/test/widgets/inherited_test.dart b/packages/flutter/test/widgets/inherited_test.dart index 97b4968b7c..d1931041b1 100644 --- a/packages/flutter/test/widgets/inherited_test.dart +++ b/packages/flutter/test/widgets/inherited_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'test_widgets.dart'; class TestInherited extends InheritedWidget { - TestInherited({ Key key, Widget child, this.shouldNotify: true }) + const TestInherited({ Key key, Widget child, this.shouldNotify: true }) : super(key: key, child: child); final bool shouldNotify; @@ -20,7 +20,7 @@ class TestInherited extends InheritedWidget { } class ValueInherited extends InheritedWidget { - ValueInherited({ Key key, Widget child, this.value }) + const ValueInherited({ Key key, Widget child, this.value }) : super(key: key, child: child); final int value; @@ -30,7 +30,7 @@ class ValueInherited extends InheritedWidget { } class ExpectFail extends StatefulWidget { - ExpectFail(this.onError); + const ExpectFail(this.onError); final VoidCallback onError; @override diff --git a/packages/flutter/test/widgets/layout_builder_and_global_keys_test.dart b/packages/flutter/test/widgets/layout_builder_and_global_keys_test.dart index 07e6248ddc..c0250fdd24 100644 --- a/packages/flutter/test/widgets/layout_builder_and_global_keys_test.dart +++ b/packages/flutter/test/widgets/layout_builder_and_global_keys_test.dart @@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart' hide TypeMatcher; import 'package:flutter/widgets.dart'; class Wrapper extends StatelessWidget { - Wrapper({ + const Wrapper({ Key key, this.child, }) : super(key: key); @@ -18,7 +18,7 @@ class Wrapper extends StatelessWidget { } class StatefulWrapper extends StatefulWidget { - StatefulWrapper({ + const StatefulWrapper({ Key key, this.child, }) : super(key: key); diff --git a/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart b/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart index d8ddf410c2..7f25030689 100644 --- a/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart +++ b/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart @@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart' hide TypeMatcher; import 'package:flutter/widgets.dart'; class SizeChanger extends StatefulWidget { - SizeChanger({ + const SizeChanger({ Key key, this.child, }) : super(key: key); @@ -41,7 +41,7 @@ class SizeChangerState extends State { } class Wrapper extends StatelessWidget { - Wrapper({ + const Wrapper({ Key key, this.child, }) : super(key: key); diff --git a/packages/flutter/test/widgets/layout_builder_and_state_test.dart b/packages/flutter/test/widgets/layout_builder_and_state_test.dart index 5a5ba4150c..0daaea540a 100644 --- a/packages/flutter/test/widgets/layout_builder_and_state_test.dart +++ b/packages/flutter/test/widgets/layout_builder_and_state_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/widgets.dart'; import 'test_widgets.dart'; class StatefulWrapper extends StatefulWidget { - StatefulWrapper({ + const StatefulWrapper({ Key key, this.child, }) : super(key: key); @@ -34,7 +34,7 @@ class StatefulWrapperState extends State { } class Wrapper extends StatelessWidget { - Wrapper({ + const Wrapper({ Key key, this.child, }) : super(key: key); diff --git a/packages/flutter/test/widgets/modal_barrier_test.dart b/packages/flutter/test/widgets/modal_barrier_test.dart index e4be1c4f0f..671b487f05 100644 --- a/packages/flutter/test/widgets/modal_barrier_test.dart +++ b/packages/flutter/test/widgets/modal_barrier_test.dart @@ -28,7 +28,7 @@ void main() { final Widget subject = new Stack( children: [ tapTarget, - new ModalBarrier(dismissible: false), + const ModalBarrier(dismissible: false), ] ); @@ -42,7 +42,7 @@ void main() { testWidgets('ModalBarrier does not prevent interactions with widgets in front of it', (WidgetTester tester) async { final Widget subject = new Stack( children: [ - new ModalBarrier(dismissible: false), + const ModalBarrier(dismissible: false), tapTarget, ] ); @@ -97,7 +97,7 @@ class FirstWidget extends StatelessWidget { class SecondWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return new ModalBarrier( + return const ModalBarrier( key: const ValueKey('barrier'), dismissible: true ); diff --git a/packages/flutter/test/widgets/navigator_test.dart b/packages/flutter/test/widgets/navigator_test.dart index 48cab05b92..9089394c19 100644 --- a/packages/flutter/test/widgets/navigator_test.dart +++ b/packages/flutter/test/widgets/navigator_test.dart @@ -45,7 +45,7 @@ class SecondWidgetState extends State { typedef void ExceptionCallback(dynamic exception); class ThirdWidget extends StatelessWidget { - ThirdWidget({ this.targetKey, this.onException }); + const ThirdWidget({ this.targetKey, this.onException }); final Key targetKey; final ExceptionCallback onException; @@ -67,7 +67,7 @@ class ThirdWidget extends StatelessWidget { } class OnTapPage extends StatelessWidget { - OnTapPage({ Key key, this.id, this.onTap }) : super(key: key); + const OnTapPage({ Key key, this.id, this.onTap }) : super(key: key); final String id; final VoidCallback onTap; @@ -383,7 +383,7 @@ void main() { final Map routes = { '/': (BuildContext context) => new OnTapPage(id: '/', onTap: () { Navigator.pushReplacementNamed(context, '/A'); }), '/A': (BuildContext context) => new OnTapPage(id: 'A', onTap: () { Navigator.pushReplacementNamed(context, '/B'); }), - '/B': (BuildContext context) => new OnTapPage(id: 'B'), + '/B': (BuildContext context) => const OnTapPage(id: 'B'), }; await tester.pumpWidget(new MaterialApp(routes: routes)); diff --git a/packages/flutter/test/widgets/page_forward_transitions_test.dart b/packages/flutter/test/widgets/page_forward_transitions_test.dart index 13283f8ed8..31d5d2e4f6 100644 --- a/packages/flutter/test/widgets/page_forward_transitions_test.dart +++ b/packages/flutter/test/widgets/page_forward_transitions_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; class TestTransition extends AnimatedWidget { - TestTransition({ + const TestTransition({ Key key, this.childFirstHalf, this.childSecondHalf, diff --git a/packages/flutter/test/widgets/page_transitions_test.dart b/packages/flutter/test/widgets/page_transitions_test.dart index 7350992a8c..e5a4ed83c1 100644 --- a/packages/flutter/test/widgets/page_transitions_test.dart +++ b/packages/flutter/test/widgets/page_transitions_test.dart @@ -14,7 +14,7 @@ class TestOverlayRoute extends OverlayRoute { } class PersistentBottomSheetTest extends StatefulWidget { - PersistentBottomSheetTest({ Key key }) : super(key: key); + const PersistentBottomSheetTest({ Key key }) : super(key: key); @override PersistentBottomSheetTestState createState() => new PersistentBottomSheetTestState(); diff --git a/packages/flutter/test/widgets/performance_overlay_test.dart b/packages/flutter/test/widgets/performance_overlay_test.dart index 047d5c96d2..0cbc69c44c 100644 --- a/packages/flutter/test/widgets/performance_overlay_test.dart +++ b/packages/flutter/test/widgets/performance_overlay_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Performance overlay smoke test', (WidgetTester tester) async { - await tester.pumpWidget(new PerformanceOverlay()); + await tester.pumpWidget(const PerformanceOverlay()); await tester.pumpWidget(new PerformanceOverlay.allEnabled()); }); } diff --git a/packages/flutter/test/widgets/remember_scroll_position_test.dart b/packages/flutter/test/widgets/remember_scroll_position_test.dart index f3c9f64232..0d5a2db107 100644 --- a/packages/flutter/test/widgets/remember_scroll_position_test.dart +++ b/packages/flutter/test/widgets/remember_scroll_position_test.dart @@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/material.dart'; class ThePositiveNumbers extends StatelessWidget { - ThePositiveNumbers({ @required this.from }); + const ThePositiveNumbers({ @required this.from }); final int from; @override Widget build(BuildContext context) { @@ -34,12 +34,12 @@ void main() { if (settings.name == '/') { return new MaterialPageRoute( settings: settings, - builder: (_) => new Container(child: new ThePositiveNumbers(from: 0)), + builder: (_) => new Container(child: const ThePositiveNumbers(from: 0)), ); } else if (settings.name == '/second') { return new MaterialPageRoute( settings: settings, - builder: (_) => new Container(child: new ThePositiveNumbers(from: 10000)), + builder: (_) => new Container(child: const ThePositiveNumbers(from: 10000)), ); } return null; diff --git a/packages/flutter/test/widgets/render_object_widget_test.dart b/packages/flutter/test/widgets/render_object_widget_test.dart index d74828ca8b..0be61df876 100644 --- a/packages/flutter/test/widgets/render_object_widget_test.dart +++ b/packages/flutter/test/widgets/render_object_widget_test.dart @@ -21,7 +21,7 @@ class TestWidget extends StatelessWidget { } class TestOrientedBox extends SingleChildRenderObjectWidget { - TestOrientedBox({ Key key, Widget child }) : super(key: key, child: child); + const TestOrientedBox({ Key key, Widget child }) : super(key: key, child: child); Decoration _getDecoration(BuildContext context) { final Orientation orientation = MediaQuery.of(context).orientation; diff --git a/packages/flutter/test/widgets/reparent_state_harder_test.dart b/packages/flutter/test/widgets/reparent_state_harder_test.dart index e7f3aff4bf..602b4ef846 100644 --- a/packages/flutter/test/widgets/reparent_state_harder_test.dart +++ b/packages/flutter/test/widgets/reparent_state_harder_test.dart @@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart' hide TypeMatcher; // This is a regression test for https://github.com/flutter/flutter/issues/5588. class OrderSwitcher extends StatefulWidget { - OrderSwitcher({ Key key, this.a, this.b }) : super(key: key); + const OrderSwitcher({ Key key, this.a, this.b }) : super(key: key); final Widget a; final Widget b; @@ -44,7 +44,7 @@ class OrderSwitcherState extends State { } class DummyStatefulWidget extends StatefulWidget { - DummyStatefulWidget(Key key) : super(key: key); + const DummyStatefulWidget(Key key) : super(key: key); @override DummyStatefulWidgetState createState() => new DummyStatefulWidgetState(); @@ -56,7 +56,7 @@ class DummyStatefulWidgetState extends State { } class RekeyableDummyStatefulWidgetWrapper extends StatefulWidget { - RekeyableDummyStatefulWidgetWrapper({ this.child, this.initialKey }); + const RekeyableDummyStatefulWidgetWrapper({ this.child, this.initialKey }); final Widget child; final GlobalKey initialKey; @override diff --git a/packages/flutter/test/widgets/reparent_state_test.dart b/packages/flutter/test/widgets/reparent_state_test.dart index 7879dd3354..6f3ed6d0fa 100644 --- a/packages/flutter/test/widgets/reparent_state_test.dart +++ b/packages/flutter/test/widgets/reparent_state_test.dart @@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; class StateMarker extends StatefulWidget { - StateMarker({ Key key, this.child }) : super(key: key); + const StateMarker({ Key key, this.child }) : super(key: key); final Widget child; @@ -26,7 +26,7 @@ class StateMarkerState extends State { } class DeactivateLogger extends StatefulWidget { - DeactivateLogger({ Key key, this.log }) : super(key: key); + const DeactivateLogger({ Key key, this.log }) : super(key: key); final List log; @@ -53,7 +53,7 @@ void main() { final GlobalKey left = new GlobalKey(); final GlobalKey right = new GlobalKey(); - final StateMarker grandchild = new StateMarker(); + final StateMarker grandchild = const StateMarker(); await tester.pumpWidget( new Stack( children: [ @@ -79,7 +79,7 @@ void main() { expect(grandchildState, isNotNull); grandchildState.marker = "grandchild"; - final StateMarker newGrandchild = new StateMarker(); + final StateMarker newGrandchild = const StateMarker(); await tester.pumpWidget( new Stack( children: [ @@ -126,7 +126,7 @@ void main() { final GlobalKey left = new GlobalKey(); final GlobalKey right = new GlobalKey(); - final StateMarker grandchild = new StateMarker(); + final StateMarker grandchild = const StateMarker(); await tester.pumpWidget( new Stack( children: [ @@ -148,7 +148,7 @@ void main() { expect(grandchildState, isNotNull); grandchildState.marker = "grandchild"; - final StateMarker newGrandchild = new StateMarker(); + final StateMarker newGrandchild = const StateMarker(); await tester.pumpWidget( new Stack( children: [ diff --git a/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart b/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart index 2861a9cea9..e5c281891d 100644 --- a/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart +++ b/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart @@ -46,7 +46,7 @@ class BarState extends State { } class StatefulCreationCounter extends StatefulWidget { - StatefulCreationCounter({ Key key }) : super(key: key); + const StatefulCreationCounter({ Key key }) : super(key: key); @override StatefulCreationCounterState createState() => new StatefulCreationCounterState(); diff --git a/packages/flutter/test/widgets/scroll_behavior_test.dart b/packages/flutter/test/widgets/scroll_behavior_test.dart index e0b25cda50..718d6daaeb 100644 --- a/packages/flutter/test/widgets/scroll_behavior_test.dart +++ b/packages/flutter/test/widgets/scroll_behavior_test.dart @@ -6,7 +6,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; class TestScrollBehavior extends ScrollBehavior { - TestScrollBehavior(this.flag); + const TestScrollBehavior(this.flag); final bool flag; @@ -40,7 +40,7 @@ void main() { await tester.pumpWidget( new ScrollConfiguration( - behavior: new TestScrollBehavior(true), + behavior: const TestScrollBehavior(true), child: scrollView, ), ); @@ -55,7 +55,7 @@ void main() { // Same Scrollable, different ScrollConfiguration await tester.pumpWidget( new ScrollConfiguration( - behavior: new TestScrollBehavior(false), + behavior: const TestScrollBehavior(false), child: scrollView, ), ); diff --git a/packages/flutter/test/widgets/scrollable_custom_scroll_behavior_test.dart b/packages/flutter/test/widgets/scrollable_custom_scroll_behavior_test.dart index be0e2049ed..f458900391 100644 --- a/packages/flutter/test/widgets/scrollable_custom_scroll_behavior_test.dart +++ b/packages/flutter/test/widgets/scrollable_custom_scroll_behavior_test.dart @@ -94,7 +94,7 @@ class TestScrollController extends ScrollController { } class TestScrollBehavior extends ScrollBehavior { - TestScrollBehavior(this.extentMultiplier); + const TestScrollBehavior(this.extentMultiplier); final double extentMultiplier; @@ -117,7 +117,7 @@ class TestScrollBehavior extends ScrollBehavior { void main() { testWidgets('Changing the scroll behavior dynamically', (WidgetTester tester) async { await tester.pumpWidget(new ScrollConfiguration( - behavior: new TestScrollBehavior(1.0), + behavior: const TestScrollBehavior(1.0), child: new CustomScrollView( controller: new TestScrollController(), slivers: [ @@ -129,7 +129,7 @@ void main() { expect(state.position.getMetrics().extentInside, 1.0); await tester.pumpWidget(new ScrollConfiguration( - behavior: new TestScrollBehavior(2.0), + behavior: const TestScrollBehavior(2.0), child: new CustomScrollView( controller: new TestScrollController(), slivers: [ diff --git a/packages/flutter/test/widgets/scrollable_of_test.dart b/packages/flutter/test/widgets/scrollable_of_test.dart index fa3f6f18a5..5abb59f2a2 100644 --- a/packages/flutter/test/widgets/scrollable_of_test.dart +++ b/packages/flutter/test/widgets/scrollable_of_test.dart @@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; class ScrollPositionListener extends StatefulWidget { - ScrollPositionListener({ Key key, this.child, this.log}) : super(key: key); + const ScrollPositionListener({ Key key, this.child, this.log}) : super(key: key); final Widget child; final ValueChanged log; diff --git a/packages/flutter/test/widgets/set_state_1_test.dart b/packages/flutter/test/widgets/set_state_1_test.dart index 8de154a71b..5057390490 100644 --- a/packages/flutter/test/widgets/set_state_1_test.dart +++ b/packages/flutter/test/widgets/set_state_1_test.dart @@ -25,7 +25,7 @@ class InsideState extends State { } class Middle extends StatefulWidget { - Middle({ this.child }); + const Middle({ this.child }); final Inside child; diff --git a/packages/flutter/test/widgets/set_state_3_test.dart b/packages/flutter/test/widgets/set_state_3_test.dart index db234ae4ff..be2bfef7cb 100644 --- a/packages/flutter/test/widgets/set_state_3_test.dart +++ b/packages/flutter/test/widgets/set_state_3_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart'; ChangerState changer; class Changer extends StatefulWidget { - Changer(this.child); + const Changer(this.child); final Widget child; @@ -32,7 +32,7 @@ class ChangerState extends State { } class Wrapper extends StatelessWidget { - Wrapper(this.child); + const Wrapper(this.child); final Widget child; diff --git a/packages/flutter/test/widgets/size_changed_layout_notification_test.dart b/packages/flutter/test/widgets/size_changed_layout_notification_test.dart index cc1f354c38..ffaac235a7 100644 --- a/packages/flutter/test/widgets/size_changed_layout_notification_test.dart +++ b/packages/flutter/test/widgets/size_changed_layout_notification_test.dart @@ -23,7 +23,7 @@ void main() { onNotification: (LayoutChangedNotification notification) { throw new Exception('Should not reach this point.'); }, - child: new SizeChangedLayoutNotifier( + child: const SizeChangedLayoutNotifier( child: const SizedBox( width: 100.0, height: 100.0, @@ -41,7 +41,7 @@ void main() { notified = true; return true; }, - child: new SizeChangedLayoutNotifier( + child: const SizeChangedLayoutNotifier( child: const SizedBox( width: 200.0, height: 100.0, diff --git a/packages/flutter/test/widgets/slivers_appbar_floating_test.dart b/packages/flutter/test/widgets/slivers_appbar_floating_test.dart index e833f9e989..cf42bb3e51 100644 --- a/packages/flutter/test/widgets/slivers_appbar_floating_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_floating_test.dart @@ -28,9 +28,9 @@ void main() { await tester.pumpWidget( new CustomScrollView( slivers: [ - new BigSliver(height: bigHeight), + const BigSliver(height: bigHeight), new SliverPersistentHeader(delegate: new TestDelegate(), floating: true), - new BigSliver(height: bigHeight), + const BigSliver(height: bigHeight), ], ), ); @@ -255,7 +255,7 @@ class RenderBigSliver extends RenderSliver { } class BigSliver extends LeafRenderObjectWidget { - BigSliver({ Key key, this.height }) : super(key: key); + const BigSliver({ Key key, this.height }) : super(key: key); final double height; diff --git a/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart b/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart index be89707864..7d37ef2a3a 100644 --- a/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart @@ -262,7 +262,7 @@ class RenderBigSliver extends RenderSliver { } class BigSliver extends LeafRenderObjectWidget { - BigSliver({ Key key, this.height }) : super(key: key); + const BigSliver({ Key key, this.height }) : super(key: key); final double height; diff --git a/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart b/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart index 8b9f7ac49a..346a8a181e 100644 --- a/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart @@ -53,10 +53,10 @@ void main() { await tester.pumpWidget( new CustomScrollView( slivers: [ - new BigSliver(), + const BigSliver(), new SliverPersistentHeader(key: key, delegate: delegate), - new BigSliver(), - new BigSliver(), + const BigSliver(), + const BigSliver(), ], ), ); @@ -130,7 +130,7 @@ class RenderBigSliver extends RenderSliver { } class BigSliver extends LeafRenderObjectWidget { - BigSliver({ Key key }) : super(key: key); + const BigSliver({ Key key }) : super(key: key); @override RenderBigSliver createRenderObject(BuildContext context) { return new RenderBigSliver(); diff --git a/packages/flutter/test/widgets/slivers_block_global_key_test.dart b/packages/flutter/test/widgets/slivers_block_global_key_test.dart index 0bba4f3edd..ce561f2bc7 100644 --- a/packages/flutter/test/widgets/slivers_block_global_key_test.dart +++ b/packages/flutter/test/widgets/slivers_block_global_key_test.dart @@ -9,7 +9,7 @@ import 'package:flutter/widgets.dart'; int globalGeneration = 0; class GenerationText extends StatefulWidget { - GenerationText(this.value); + const GenerationText(this.value); final int value; @override _GenerationTextState createState() => new _GenerationTextState(); diff --git a/packages/flutter/test/widgets/slivers_protocol_test.dart b/packages/flutter/test/widgets/slivers_protocol_test.dart index ef41f751c3..88a2c14337 100644 --- a/packages/flutter/test/widgets/slivers_protocol_test.dart +++ b/packages/flutter/test/widgets/slivers_protocol_test.dart @@ -65,7 +65,7 @@ class RenderBigSliver extends RenderSliver { } class BigSliver extends LeafRenderObjectWidget { - BigSliver({ Key key }) : super(key: key); + const BigSliver({ Key key }) : super(key: key); @override RenderBigSliver createRenderObject(BuildContext context) { return new RenderBigSliver(); @@ -102,7 +102,7 @@ class RenderOverlappingSliver extends RenderSliver { } class OverlappingSliver extends LeafRenderObjectWidget { - OverlappingSliver({ Key key }) : super(key: key); + const OverlappingSliver({ Key key }) : super(key: key); @override RenderOverlappingSliver createRenderObject(BuildContext context) { return new RenderOverlappingSliver(); diff --git a/packages/flutter/test/widgets/stateful_components_test.dart b/packages/flutter/test/widgets/stateful_components_test.dart index b8f0a2f9cd..b2bae20c16 100644 --- a/packages/flutter/test/widgets/stateful_components_test.dart +++ b/packages/flutter/test/widgets/stateful_components_test.dart @@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; class InnerWidget extends StatefulWidget { - InnerWidget({ Key key }) : super(key: key); + const InnerWidget({ Key key }) : super(key: key); @override InnerWidgetState createState() => new InnerWidgetState(); @@ -28,7 +28,7 @@ class InnerWidgetState extends State { } class OuterContainer extends StatefulWidget { - OuterContainer({ Key key, this.child }) : super(key: key); + const OuterContainer({ Key key, this.child }) : super(key: key); final InnerWidget child; diff --git a/packages/flutter/test/widgets/status_transitions_test.dart b/packages/flutter/test/widgets/status_transitions_test.dart index 419d05056d..b918aec19e 100644 --- a/packages/flutter/test/widgets/status_transitions_test.dart +++ b/packages/flutter/test/widgets/status_transitions_test.dart @@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; class TestStatusTransitionWidget extends StatusTransitionWidget { - TestStatusTransitionWidget({ + const TestStatusTransitionWidget({ Key key, this.builder, Animation animation, diff --git a/packages/flutter/test/widgets/syncing_test.dart b/packages/flutter/test/widgets/syncing_test.dart index 05293878ad..13bb2b8a47 100644 --- a/packages/flutter/test/widgets/syncing_test.dart +++ b/packages/flutter/test/widgets/syncing_test.dart @@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; class TestWidget extends StatefulWidget { - TestWidget({ this.child, this.persistentState, this.syncedState }); + const TestWidget({ this.child, this.persistentState, this.syncedState }); final Widget child; final int persistentState; @@ -112,8 +112,8 @@ void main() { }); testWidgets('swap instances around', (WidgetTester tester) async { - final Widget a = new TestWidget(persistentState: 0x61, syncedState: 0x41, child: const Text('apple')); - final Widget b = new TestWidget(persistentState: 0x62, syncedState: 0x42, child: const Text('banana')); + final Widget a = const TestWidget(persistentState: 0x61, syncedState: 0x41, child: const Text('apple')); + final Widget b = const TestWidget(persistentState: 0x62, syncedState: 0x42, child: const Text('banana')); await tester.pumpWidget(new Column()); final GlobalKey keyA = new GlobalKey(); diff --git a/packages/flutter/test/widgets/table_test.dart b/packages/flutter/test/widgets/table_test.dart index 39c4c1350c..076e70532a 100644 --- a/packages/flutter/test/widgets/table_test.dart +++ b/packages/flutter/test/widgets/table_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; class TestStatefulWidget extends StatefulWidget { - TestStatefulWidget({ Key key }) : super(key: key); + const TestStatefulWidget({ Key key }) : super(key: key); @override TestStatefulWidgetState createState() => new TestStatefulWidgetState(); @@ -351,15 +351,15 @@ void main() { new TableRow( key: const ValueKey(1), children: [ - new TestStatefulWidget(key: const ValueKey(11)), - new TestStatefulWidget(key: const ValueKey(12)), + const TestStatefulWidget(key: const ValueKey(11)), + const TestStatefulWidget(key: const ValueKey(12)), ], ), new TableRow( key: const ValueKey(2), children: [ - new TestStatefulWidget(key: const ValueKey(21)), - new TestStatefulWidget(key: const ValueKey(22)), + const TestStatefulWidget(key: const ValueKey(21)), + const TestStatefulWidget(key: const ValueKey(22)), ], ), ] @@ -382,8 +382,8 @@ void main() { new TableRow( key: const ValueKey(2), children: [ - new TestStatefulWidget(key: const ValueKey(21)), - new TestStatefulWidget(key: const ValueKey(22)), + const TestStatefulWidget(key: const ValueKey(21)), + const TestStatefulWidget(key: const ValueKey(22)), ], ), ] diff --git a/packages/flutter/test/widgets/test_widgets.dart b/packages/flutter/test/widgets/test_widgets.dart index a0d1b4badd..d65e08ed30 100644 --- a/packages/flutter/test/widgets/test_widgets.dart +++ b/packages/flutter/test/widgets/test_widgets.dart @@ -30,7 +30,7 @@ class TestBuildCounter extends StatelessWidget { class FlipWidget extends StatefulWidget { - FlipWidget({ Key key, this.left, this.right }) : super(key: key); + const FlipWidget({ Key key, this.left, this.right }) : super(key: key); final Widget left; final Widget right; diff --git a/packages/flutter/test/widgets/transitions_test.dart b/packages/flutter/test/widgets/transitions_test.dart index 5e8f89c098..d457759250 100644 --- a/packages/flutter/test/widgets/transitions_test.dart +++ b/packages/flutter/test/widgets/transitions_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('toString control test', (WidgetTester tester) async { - final Widget widget = new FadeTransition( + final Widget widget = const FadeTransition( opacity: kAlwaysCompleteAnimation, child: const Text('Ready'), ); @@ -52,16 +52,16 @@ void main() { }); testWidgets( - 'decoration test', + 'decoration test', (WidgetTester tester) async { - final DecoratedBoxTransition transitionUnderTest = + final DecoratedBoxTransition transitionUnderTest = new DecoratedBoxTransition( decoration: decorationTween.animate(controller), child: const Text("Doesn't matter"), ); - + await tester.pumpWidget(transitionUnderTest); - RenderDecoratedBox actualBox = + RenderDecoratedBox actualBox = tester.renderObject(find.byType(DecoratedBox)); BoxDecoration actualDecoration = actualBox.decoration; @@ -99,13 +99,13 @@ void main() { ); testWidgets('animations work with curves test', (WidgetTester tester) async { - final Animation curvedDecorationAnimation = + final Animation curvedDecorationAnimation = decorationTween.animate(new CurvedAnimation( parent: controller, curve: Curves.easeOut, )); - - final DecoratedBoxTransition transitionUnderTest = + + final DecoratedBoxTransition transitionUnderTest = new DecoratedBoxTransition( decoration: curvedDecorationAnimation, position: DecorationPosition.foreground, @@ -113,7 +113,7 @@ void main() { ); await tester.pumpWidget(transitionUnderTest); - RenderDecoratedBox actualBox = + RenderDecoratedBox actualBox = tester.renderObject(find.byType(DecoratedBox)); BoxDecoration actualDecoration = actualBox.decoration; @@ -128,7 +128,7 @@ void main() { actualBox = tester.renderObject(find.byType(DecoratedBox)); actualDecoration = actualBox.decoration; - // Same as the test above but the values should be much closer to the + // Same as the test above but the values should be much closer to the // tween's end values given the easeOut curve. expect(actualDecoration.backgroundColor, const Color(0xFF505050)); expect(actualDecoration.border.left.width, closeTo(1.9, 0.1)); diff --git a/packages/flutter/test/widgets/unique_widget_test.dart b/packages/flutter/test/widgets/unique_widget_test.dart index 6e0bee197f..69fa1ba9d6 100644 --- a/packages/flutter/test/widgets/unique_widget_test.dart +++ b/packages/flutter/test/widgets/unique_widget_test.dart @@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; class TestUniqueWidget extends UniqueWidget { - TestUniqueWidget({ GlobalKey key }) : super(key: key); + const TestUniqueWidget({ GlobalKey key }) : super(key: key); @override TestUniqueWidgetState createState() => new TestUniqueWidgetState(); diff --git a/packages/flutter_markdown/example/demo.dart b/packages/flutter_markdown/example/demo.dart index 3a99dd6ce5..41336ab84d 100644 --- a/packages/flutter_markdown/example/demo.dart +++ b/packages/flutter_markdown/example/demo.dart @@ -31,7 +31,7 @@ void main() { title: "Markdown Demo", home: new Scaffold( appBar: new AppBar(title: const Text('Markdown Demo')), - body: new Markdown(data: _kMarkdownData) + body: const Markdown(data: _kMarkdownData) ) )); } diff --git a/packages/flutter_markdown/lib/src/widget.dart b/packages/flutter_markdown/lib/src/widget.dart index 52f9cac855..974b2cde36 100644 --- a/packages/flutter_markdown/lib/src/widget.dart +++ b/packages/flutter_markdown/lib/src/widget.dart @@ -37,15 +37,14 @@ abstract class MarkdownWidget extends StatefulWidget { /// Creates a widget that parses and displays Markdown. /// /// The [data] argument must not be null. - MarkdownWidget({ + const MarkdownWidget({ Key key, @required this.data, this.styleSheet, this.syntaxHighlighter, this.onTapLink, - }) : super(key: key) { - assert(data != null); - } + }) : assert(data != null), + super(key: key); /// The Markdown to display. final String data; @@ -150,7 +149,7 @@ class _MarkdownWidgetState extends State implements MarkdownBuil /// * class MarkdownBody extends MarkdownWidget { /// Creates a non-scrolling widget that parses and displays Markdown. - MarkdownBody({ + const MarkdownBody({ Key key, String data, MarkdownStyleSheet styleSheet, @@ -186,7 +185,7 @@ class MarkdownBody extends MarkdownWidget { /// * class Markdown extends MarkdownWidget { /// Creates a scrolling widget that parses and displays Markdown. - Markdown({ + const Markdown({ Key key, String data, MarkdownStyleSheet styleSheet, diff --git a/packages/flutter_markdown/test/flutter_markdown_test.dart b/packages/flutter_markdown/test/flutter_markdown_test.dart index 42301e7781..73d5ca57bf 100644 --- a/packages/flutter_markdown/test/flutter_markdown_test.dart +++ b/packages/flutter_markdown/test/flutter_markdown_test.dart @@ -10,7 +10,7 @@ import 'package:flutter/material.dart'; void main() { testWidgets('Simple string', (WidgetTester tester) async { - await tester.pumpWidget(new MarkdownBody(data: 'Hello')); + await tester.pumpWidget(const MarkdownBody(data: 'Hello')); final Iterable widgets = tester.allWidgets; _expectWidgetTypes(widgets, [MarkdownBody, Column, RichText]); @@ -18,7 +18,7 @@ void main() { }); testWidgets('Header', (WidgetTester tester) async { - await tester.pumpWidget(new MarkdownBody(data: '# Header')); + await tester.pumpWidget(const MarkdownBody(data: '# Header')); final Iterable widgets = tester.allWidgets; _expectWidgetTypes(widgets, [MarkdownBody, Column, RichText]); @@ -26,14 +26,14 @@ void main() { }); testWidgets('Empty string', (WidgetTester tester) async { - await tester.pumpWidget(new MarkdownBody(data: '')); + await tester.pumpWidget(const MarkdownBody(data: '')); final Iterable widgets = tester.allWidgets; _expectWidgetTypes(widgets, [MarkdownBody, Column]); }); testWidgets('Ordered list', (WidgetTester tester) async { - await tester.pumpWidget(new MarkdownBody(data: '1. Item 1\n1. Item 2\n2. Item 3')); + await tester.pumpWidget(const MarkdownBody(data: '1. Item 1\n1. Item 2\n2. Item 3')); final Iterable widgets = tester.allWidgets; _expectTextStrings(widgets, [ @@ -47,7 +47,7 @@ void main() { }); testWidgets('Unordered list', (WidgetTester tester) async { - await tester.pumpWidget(new MarkdownBody(data: '- Item 1\n- Item 2\n- Item 3')); + await tester.pumpWidget(const MarkdownBody(data: '- Item 1\n- Item 2\n- Item 3')); final Iterable widgets = tester.allWidgets; _expectTextStrings(widgets, [ @@ -61,7 +61,7 @@ void main() { }); testWidgets('Scrollable wrapping', (WidgetTester tester) async { - await tester.pumpWidget(new Markdown(data: '')); + await tester.pumpWidget(const Markdown(data: '')); final List widgets = tester.allWidgets.toList(); _expectWidgetTypes(widgets.take(2), [ @@ -75,7 +75,7 @@ void main() { }); testWidgets('Links', (WidgetTester tester) async { - await tester.pumpWidget(new Markdown(data: '[Link Text](href)')); + await tester.pumpWidget(const Markdown(data: '[Link Text](href)')); final RichText textWidget = tester.allWidgets.firstWhere((Widget widget) => widget is RichText); final TextSpan span = textWidget.text; @@ -106,15 +106,15 @@ void main() { }); testWidgets('Changing config - data', (WidgetTester tester) async { - await tester.pumpWidget(new Markdown(data: 'Data1')); + await tester.pumpWidget(const Markdown(data: 'Data1')); _expectTextStrings(tester.allWidgets, ['Data1']); final String stateBefore = _dumpRenderView(); - await tester.pumpWidget(new Markdown(data: 'Data1')); + await tester.pumpWidget(const Markdown(data: 'Data1')); final String stateAfter = _dumpRenderView(); expect(stateBefore, equals(stateAfter)); - await tester.pumpWidget(new Markdown(data: 'Data2')); + await tester.pumpWidget(const Markdown(data: 'Data2')); _expectTextStrings(tester.allWidgets, ['Data2']); });