diff --git a/examples/catalog/lib/animated_list.dart b/examples/catalog/lib/animated_list.dart index 6fcba2eddda..85101a74292 100644 --- a/examples/catalog/lib/animated_list.dart +++ b/examples/catalog/lib/animated_list.dart @@ -152,7 +152,7 @@ class ListModel { /// This widget's height is based on the animation parameter, it varies /// from 0 to 128 as the animation varies from 0.0 to 1.0. class CardItem extends StatelessWidget { - CardItem({ + const CardItem({ Key key, @required this.animation, this.onTap, diff --git a/examples/catalog/lib/expansion_tile_sample.dart b/examples/catalog/lib/expansion_tile_sample.dart index 2213ee18c55..a61ff8676d8 100644 --- a/examples/catalog/lib/expansion_tile_sample.dart +++ b/examples/catalog/lib/expansion_tile_sample.dart @@ -68,7 +68,7 @@ final List data = [ // Displays one Entry. If the entry has children then it's displayed // with an ExpansionTile. class EntryItem extends StatelessWidget { - EntryItem(this.entry); + const EntryItem(this.entry); final Entry entry; diff --git a/examples/flutter_gallery/lib/demo/animation/home.dart b/examples/flutter_gallery/lib/demo/animation/home.dart index e01e158d1b4..503b766a930 100644 --- a/examples/flutter_gallery/lib/demo/animation/home.dart +++ b/examples/flutter_gallery/lib/demo/animation/home.dart @@ -75,7 +75,7 @@ class _RenderStatusBarPaddingSliver extends RenderSliver { } class _StatusBarPaddingSliver extends SingleChildRenderObjectWidget { - _StatusBarPaddingSliver({ + const _StatusBarPaddingSliver({ Key key, @required this.maxHeight, this.scrollFactor: 5.0, @@ -369,7 +369,7 @@ class _AllSectionsView extends AnimatedWidget { // app bar's height is _kAppBarMidHeight and only one section heading is // visible. class _SnappingScrollPhysics extends ClampingScrollPhysics { - _SnappingScrollPhysics({ + const _SnappingScrollPhysics({ ScrollPhysics parent, @required this.midScrollOffset, }) : assert(midScrollOffset != null), diff --git a/examples/flutter_gallery/lib/demo/animation/widgets.dart b/examples/flutter_gallery/lib/demo/animation/widgets.dart index c00945010e3..1207acc13b4 100644 --- a/examples/flutter_gallery/lib/demo/animation/widgets.dart +++ b/examples/flutter_gallery/lib/demo/animation/widgets.dart @@ -11,7 +11,7 @@ const double kSectionIndicatorWidth = 32.0; // The card for a single section. Displays the section's gradient and background image. class SectionCard extends StatelessWidget { - SectionCard({ Key key, @required this.section }) + const SectionCard({ Key key, @required this.section }) : assert(section != null), super(key: key); @@ -60,7 +60,7 @@ class SectionTitle extends StatelessWidget { color: const Color(0x19000000), ); - SectionTitle({ + const SectionTitle({ Key key, @required this.section, @required this.scale, diff --git a/examples/flutter_gallery/lib/demo/colors_demo.dart b/examples/flutter_gallery/lib/demo/colors_demo.dart index f76eae777f1..35a1be8a5d9 100644 --- a/examples/flutter_gallery/lib/demo/colors_demo.dart +++ b/examples/flutter_gallery/lib/demo/colors_demo.dart @@ -42,7 +42,7 @@ final List allPalettes = [ class ColorItem extends StatelessWidget { - ColorItem({ + const ColorItem({ Key key, @required this.index, @required this.color, diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart index c4b035e8912..4383bedc305 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart @@ -116,7 +116,7 @@ class _ShrineGridDelegate extends SliverGridDelegate { // Displays the Vendor's name and avatar. class _VendorItem extends StatelessWidget { - _VendorItem({ Key key, @required this.vendor }) + const _VendorItem({ Key key, @required this.vendor }) : assert(vendor != null), super(key: key); @@ -294,7 +294,7 @@ class _Heading extends StatelessWidget { // A card that displays a product's image, price, and vendor. The _ProductItem // cards appear in a grid below the heading. class _ProductItem extends StatelessWidget { - _ProductItem({ Key key, @required this.product, this.onPressed }) + const _ProductItem({ Key key, @required this.product, this.onPressed }) : assert(product != null), super(key: key); diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart index a8c373914ee..a55f37b08ea 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart @@ -12,7 +12,7 @@ import 'shrine_types.dart'; // Displays the product title's, description, and order quantity dropdown. class _ProductItem extends StatelessWidget { - _ProductItem({ + const _ProductItem({ Key key, @required this.product, @required this.quantity, @@ -69,7 +69,7 @@ class _ProductItem extends StatelessWidget { // Vendor name and description class _VendorItem extends StatelessWidget { - _VendorItem({ Key key, @required this.vendor }) + const _VendorItem({ Key key, @required this.vendor }) : assert(vendor != null), super(key: key); @@ -140,7 +140,7 @@ class _HeadingLayout extends MultiChildLayoutDelegate { // Describes a product and vendor in detail, supports specifying // a order quantity (0-5). Appears at the top of the OrderPage. class _Heading extends StatelessWidget { - _Heading({ + const _Heading({ Key key, @required this.product, @required this.quantity, diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart index 908a8375c91..d6c401860af 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart @@ -15,7 +15,7 @@ enum ShrineAction { } class ShrinePage extends StatefulWidget { - ShrinePage({ + const ShrinePage({ Key key, @required this.scaffoldKey, @required this.body, diff --git a/examples/flutter_gallery/lib/demo/typography_demo.dart b/examples/flutter_gallery/lib/demo/typography_demo.dart index 9dd9181da7b..b39f6328dff 100644 --- a/examples/flutter_gallery/lib/demo/typography_demo.dart +++ b/examples/flutter_gallery/lib/demo/typography_demo.dart @@ -6,7 +6,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class TextStyleItem extends StatelessWidget { - TextStyleItem({ + const TextStyleItem({ Key key, @required this.name, @required this.style, diff --git a/examples/flutter_gallery/lib/gallery/drawer.dart b/examples/flutter_gallery/lib/gallery/drawer.dart index 8a5f2ef27eb..900719c18e1 100644 --- a/examples/flutter_gallery/lib/gallery/drawer.dart +++ b/examples/flutter_gallery/lib/gallery/drawer.dart @@ -88,7 +88,7 @@ class _GalleryDrawerHeaderState extends State { } class GalleryDrawer extends StatelessWidget { - GalleryDrawer({ + const GalleryDrawer({ Key key, this.useLightTheme, @required this.onThemeChanged, diff --git a/examples/flutter_gallery/lib/gallery/home.dart b/examples/flutter_gallery/lib/gallery/home.dart index 9f1ebb22419..03a766e2735 100644 --- a/examples/flutter_gallery/lib/gallery/home.dart +++ b/examples/flutter_gallery/lib/gallery/home.dart @@ -66,7 +66,7 @@ class _AppBarBackground extends StatelessWidget { } class GalleryHome extends StatefulWidget { - GalleryHome({ + const GalleryHome({ Key key, this.useLightTheme, @required this.onThemeChanged, diff --git a/examples/flutter_gallery/lib/gallery/item.dart b/examples/flutter_gallery/lib/gallery/item.dart index fe118fd3cfa..dafa548b4cf 100644 --- a/examples/flutter_gallery/lib/gallery/item.dart +++ b/examples/flutter_gallery/lib/gallery/item.dart @@ -12,7 +12,7 @@ import '../demo/all.dart'; typedef Widget GalleryDemoBuilder(); class GalleryItem extends StatelessWidget { - GalleryItem({ + const GalleryItem({ @required this.title, this.subtitle, @required this.category, diff --git a/examples/flutter_gallery/lib/gallery/updates.dart b/examples/flutter_gallery/lib/gallery/updates.dart index e100fa53e54..fabafe0998e 100644 --- a/examples/flutter_gallery/lib/gallery/updates.dart +++ b/examples/flutter_gallery/lib/gallery/updates.dart @@ -12,7 +12,7 @@ import 'package:url_launcher/url_launcher.dart'; typedef Future UpdateUrlFetcher(); class Updater extends StatefulWidget { - Updater({ @required this.updateUrlFetcher, this.child, Key key }) + const Updater({ @required this.updateUrlFetcher, this.child, Key key }) : assert(updateUrlFetcher != null), super(key: key); diff --git a/examples/platform_view/lib/main.dart b/examples/platform_view/lib/main.dart index b6426b5eff3..a1ab83a1711 100644 --- a/examples/platform_view/lib/main.dart +++ b/examples/platform_view/lib/main.dart @@ -19,13 +19,13 @@ class PlatformView extends StatelessWidget { theme: new ThemeData( primarySwatch: Colors.grey, ), - home: new MyHomePage(title: 'Platform View'), + home: const MyHomePage(title: 'Platform View'), ); } } class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); + const MyHomePage({Key key, this.title}) : super(key: key); final String title; diff --git a/packages/flutter/lib/src/services/message_codec.dart b/packages/flutter/lib/src/services/message_codec.dart index 22691f44e11..7f2aebf3797 100644 --- a/packages/flutter/lib/src/services/message_codec.dart +++ b/packages/flutter/lib/src/services/message_codec.dart @@ -35,7 +35,7 @@ abstract class MessageCodec { class MethodCall { /// Creates a [MethodCall] representing the invocation of [method] with the /// specified [arguments]. - MethodCall(this.method, [this.arguments]) + const MethodCall(this.method, [this.arguments]) : assert(method != null); /// The name of the method to be called. diff --git a/packages/flutter/lib/src/widgets/animated_list.dart b/packages/flutter/lib/src/widgets/animated_list.dart index 6f0a55864ff..2b6cb747d99 100644 --- a/packages/flutter/lib/src/widgets/animated_list.dart +++ b/packages/flutter/lib/src/widgets/animated_list.dart @@ -46,7 +46,7 @@ class _ActiveItem implements Comparable<_ActiveItem> { /// This widget is similar to one created by [ListView.builder]. class AnimatedList extends StatefulWidget { /// Creates a scrolling container that animates items when they are inserted or removed. - AnimatedList({ + const AnimatedList({ Key key, @required this.itemBuilder, this.initialItemCount: 0, diff --git a/packages/flutter/lib/src/widgets/async.dart b/packages/flutter/lib/src/widgets/async.dart index f64cb8cb874..5dd926788a8 100644 --- a/packages/flutter/lib/src/widgets/async.dart +++ b/packages/flutter/lib/src/widgets/async.dart @@ -195,7 +195,7 @@ class AsyncSnapshot { const AsyncSnapshot.nothing() : this._(ConnectionState.none, null, null); /// Creates an [AsyncSnapshot] in the specified [state] and with the specified [data]. - AsyncSnapshot.withData(ConnectionState state, T data) : this._(state, data, null); // not const because https://github.com/dart-lang/sdk/issues/29432 + const AsyncSnapshot.withData(ConnectionState state, T data) : this._(state, data, null); /// Creates an [AsyncSnapshot] in the specified [state] and with the specified [error]. const AsyncSnapshot.withError(ConnectionState state, Object error) : this._(state, null, error); diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index a0f9fd8fee7..1a25d1a2efb 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -313,10 +313,10 @@ class LabeledGlobalKey> extends GlobalKey { /// Creates a global key with a debugging label. /// /// The label does not affect the key's identity. - const LabeledGlobalKey(this._debugLabel) : super.constructor(); + LabeledGlobalKey(this._debugLabel) : super.constructor(); // Used for forwarding the constructor from GlobalKey. - const LabeledGlobalKey._({ String debugLabel }) : _debugLabel = debugLabel, super.constructor(); + LabeledGlobalKey._({ String debugLabel }) : _debugLabel = debugLabel, super.constructor(); final String _debugLabel; diff --git a/packages/flutter/lib/src/widgets/nested_scroll_view.dart b/packages/flutter/lib/src/widgets/nested_scroll_view.dart index 05e2c9f26a1..2b6280ec30b 100644 --- a/packages/flutter/lib/src/widgets/nested_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/nested_scroll_view.dart @@ -36,7 +36,7 @@ typedef List NestedScrollViewHeaderSliversBuilder(BuildContext context, const double _kInitialScrollOffset = 0.0; class NestedScrollView extends StatefulWidget { - NestedScrollView({ + const NestedScrollView({ Key key, this.scrollDirection: Axis.vertical, this.reverse: false, diff --git a/packages/flutter/test/services/haptic_feedback_test.dart b/packages/flutter/test/services/haptic_feedback_test.dart index f051fb49e3f..3f029fdc89b 100644 --- a/packages/flutter/test/services/haptic_feedback_test.dart +++ b/packages/flutter/test/services/haptic_feedback_test.dart @@ -15,6 +15,6 @@ void main() { await HapticFeedback.vibrate(); - expect(log, equals([new MethodCall('HapticFeedback.vibrate')])); + expect(log, equals([const MethodCall('HapticFeedback.vibrate')])); }); } diff --git a/packages/flutter/test/services/platform_channel_test.dart b/packages/flutter/test/services/platform_channel_test.dart index 1f17812cbae..bde93d085ae 100644 --- a/packages/flutter/test/services/platform_channel_test.dart +++ b/packages/flutter/test/services/platform_channel_test.dart @@ -91,7 +91,7 @@ void main() { }); test('can handle method call with no registered plugin', () async { channel.setMethodCallHandler(null); - final ByteData call = jsonMethod.encodeMethodCall(new MethodCall('sayHello', 'hello')); + final ByteData call = jsonMethod.encodeMethodCall(const MethodCall('sayHello', 'hello')); ByteData envelope; await BinaryMessages.handlePlatformMessage('ch7', call, (ByteData result) { envelope = result; @@ -102,7 +102,7 @@ void main() { channel.setMethodCallHandler((MethodCall call) async { throw new MissingPluginException(); }); - final ByteData call = jsonMethod.encodeMethodCall(new MethodCall('sayHello', 'hello')); + final ByteData call = jsonMethod.encodeMethodCall(const MethodCall('sayHello', 'hello')); ByteData envelope; await BinaryMessages.handlePlatformMessage('ch7', call, (ByteData result) { envelope = result; @@ -111,7 +111,7 @@ void main() { }); test('can handle method call with successful result', () async { channel.setMethodCallHandler((MethodCall call) async => '${call.arguments}, world'); - final ByteData call = jsonMethod.encodeMethodCall(new MethodCall('sayHello', 'hello')); + final ByteData call = jsonMethod.encodeMethodCall(const MethodCall('sayHello', 'hello')); ByteData envelope; await BinaryMessages.handlePlatformMessage('ch7', call, (ByteData result) { envelope = result; @@ -122,7 +122,7 @@ void main() { channel.setMethodCallHandler((MethodCall call) async { throw new PlatformException(code: 'bad', message: 'sayHello failed', details: null); }); - final ByteData call = jsonMethod.encodeMethodCall(new MethodCall('sayHello', 'hello')); + final ByteData call = jsonMethod.encodeMethodCall(const MethodCall('sayHello', 'hello')); ByteData envelope; await BinaryMessages.handlePlatformMessage('ch7', call, (ByteData result) { envelope = result; @@ -141,7 +141,7 @@ void main() { channel.setMethodCallHandler((MethodCall call) async { throw new ArgumentError('bad'); }); - final ByteData call = jsonMethod.encodeMethodCall(new MethodCall('sayHello', 'hello')); + final ByteData call = jsonMethod.encodeMethodCall(const MethodCall('sayHello', 'hello')); ByteData envelope; await BinaryMessages.handlePlatformMessage('ch7', call, (ByteData result) { envelope = result; diff --git a/packages/flutter/test/services/system_navigator_test.dart b/packages/flutter/test/services/system_navigator_test.dart index 828e80b983d..a6937617164 100644 --- a/packages/flutter/test/services/system_navigator_test.dart +++ b/packages/flutter/test/services/system_navigator_test.dart @@ -15,6 +15,6 @@ void main() { await SystemNavigator.pop(); - expect(log, equals([new MethodCall('SystemNavigator.pop')])); + expect(log, equals([const MethodCall('SystemNavigator.pop')])); }); } diff --git a/packages/flutter/test/services/system_sound_test.dart b/packages/flutter/test/services/system_sound_test.dart index f06683919c9..38b4f81a521 100644 --- a/packages/flutter/test/services/system_sound_test.dart +++ b/packages/flutter/test/services/system_sound_test.dart @@ -8,13 +8,13 @@ import 'package:test/test.dart'; void main() { test('System sound control test', () async { final List log = []; - + SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async { log.add(methodCall); }); - + await SystemSound.play(SystemSoundType.click); - expect(log, equals([new MethodCall('SystemSound.play', "SystemSoundType.click")])); + expect(log, equals([const MethodCall('SystemSound.play', "SystemSoundType.click")])); }); } diff --git a/packages/flutter/test/widgets/async_test.dart b/packages/flutter/test/widgets/async_test.dart index 684c8b2a76d..ad5bade6959 100644 --- a/packages/flutter/test/widgets/async_test.dart +++ b/packages/flutter/test/widgets/async_test.dart @@ -14,7 +14,7 @@ void main() { group('AsyncSnapshot', () { test('requiring data succeeds if data is present', () { expect( - new AsyncSnapshot.withData(ConnectionState.done, 'hello').requireData, + const AsyncSnapshot.withData(ConnectionState.done, 'hello').requireData, 'hello', ); }); diff --git a/packages/flutter/test/widgets/layout_builder_mutations_test.dart b/packages/flutter/test/widgets/layout_builder_mutations_test.dart index 79a09b5ef9f..1eff184584d 100644 --- a/packages/flutter/test/widgets/layout_builder_mutations_test.dart +++ b/packages/flutter/test/widgets/layout_builder_mutations_test.dart @@ -9,7 +9,7 @@ import 'package:flutter/src/widgets/layout_builder.dart'; import 'package:flutter_test/flutter_test.dart' hide TypeMatcher; class Wrapper extends StatelessWidget { - Wrapper({ + const Wrapper({ Key key, @required this.child }) : assert(child != null),