Unverified Commit 0f568298 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

enable use_key_in_widget_constructors lint (#77032)

parent 6ec90142
......@@ -168,8 +168,8 @@ linter:
- prefer_if_null_operators
- prefer_initializing_formals
- prefer_inlined_adds
# - prefer_int_literals # not yet tested
# - prefer_interpolation_to_compose_strings # not yet tested
# - prefer_int_literals # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-double-literals-for-double-constants
# - prefer_interpolation_to_compose_strings # doesn't work with raw strings, see https://github.com/dart-lang/linter/issues/2490
- prefer_is_empty
- prefer_is_not_empty
- prefer_is_not_operator
......@@ -220,7 +220,7 @@ linter:
# - use_function_type_syntax_for_parameters # not yet tested
# - use_if_null_to_convert_nulls_to_bools # not yet tested
- use_is_even_rather_than_modulo
# - use_key_in_widget_constructors # not yet tested
- use_key_in_widget_constructors
- use_late_for_private_fields_and_variables
# - use_named_constants # not yet yested
- use_raw_strings
......
......@@ -7,13 +7,15 @@ import 'package:flutter/scheduler.dart' show timeDilation;
void main() {
runApp(
ComplexLayoutApp()
const ComplexLayoutApp()
);
}
enum ScrollMode { complex, tile }
class ComplexLayoutApp extends StatefulWidget {
const ComplexLayoutApp({Key key}) : super(key: key);
@override
ComplexLayoutAppState createState() => ComplexLayoutAppState();
......@@ -68,7 +70,7 @@ class TileScrollLayout extends StatelessWidget {
child: Material(
elevation: (index % 5 + 1).toDouble(),
color: Colors.white,
child: IconBar(),
child: const IconBar(),
),
);
},
......@@ -101,7 +103,7 @@ class ComplexLayoutState extends State<ComplexLayout> {
print('Pressed search');
},
),
TopBarMenu(),
const TopBarMenu(),
],
),
body: Column(
......@@ -118,7 +120,7 @@ class ComplexLayoutState extends State<ComplexLayout> {
},
),
),
BottomBar(),
const BottomBar(),
],
),
drawer: const GalleryDrawer(),
......@@ -127,6 +129,8 @@ class ComplexLayoutState extends State<ComplexLayout> {
}
class TopBarMenu extends StatelessWidget {
const TopBarMenu({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return PopupMenuButton<String>(
......@@ -178,7 +182,7 @@ class TopBarMenu extends StatelessWidget {
}
class MenuItemWithIcon extends StatelessWidget {
const MenuItemWithIcon(this.icon, this.title, this.subtitle);
const MenuItemWithIcon(this.icon, this.title, this.subtitle, {Key key}) : super(key: key);
final IconData icon;
final String title;
......@@ -209,15 +213,15 @@ class FancyImageItem extends StatelessWidget {
return ListBody(
children: <Widget>[
UserHeader('Ali Connors $index'),
ItemDescription(),
ItemImageBox(),
InfoBar(),
const ItemDescription(),
const ItemImageBox(),
const InfoBar(),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 8.0),
child: Divider(),
),
IconBar(),
FatDivider(),
const IconBar(),
const FatDivider(),
],
);
}
......@@ -233,19 +237,21 @@ class FancyGalleryItem extends StatelessWidget {
children: <Widget>[
const UserHeader('Ali Connors'),
ItemGalleryBox(index),
InfoBar(),
const InfoBar(),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 8.0),
child: Divider(),
),
IconBar(),
FatDivider(),
const IconBar(),
const FatDivider(),
],
);
}
}
class InfoBar extends StatelessWidget {
const InfoBar({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
......@@ -262,6 +268,8 @@ class InfoBar extends StatelessWidget {
}
class IconBar extends StatelessWidget {
const IconBar({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
......@@ -279,7 +287,7 @@ class IconBar extends StatelessWidget {
}
class IconWithText extends StatelessWidget {
const IconWithText(this.icon, this.title);
const IconWithText(this.icon, this.title, {Key key}) : super(key: key);
final IconData icon;
final String title;
......@@ -300,7 +308,7 @@ class IconWithText extends StatelessWidget {
}
class MiniIconWithText extends StatelessWidget {
const MiniIconWithText(this.icon, this.title);
const MiniIconWithText(this.icon, this.title, {Key key}) : super(key: key);
final IconData icon;
final String title;
......@@ -329,6 +337,8 @@ class MiniIconWithText extends StatelessWidget {
}
class FatDivider extends StatelessWidget {
const FatDivider({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
......@@ -339,7 +349,7 @@ class FatDivider extends StatelessWidget {
}
class UserHeader extends StatelessWidget {
const UserHeader(this.userName);
const UserHeader(this.userName, {Key key}) : super(key: key);
final String userName;
......@@ -380,7 +390,7 @@ class UserHeader extends StatelessWidget {
],
),
),
TopBarMenu(),
const TopBarMenu(),
],
),
);
......@@ -388,6 +398,8 @@ class UserHeader extends StatelessWidget {
}
class ItemDescription extends StatelessWidget {
const ItemDescription({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Padding(
......@@ -398,6 +410,8 @@ class ItemDescription extends StatelessWidget {
}
class ItemImageBox extends StatelessWidget {
const ItemImageBox({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
......@@ -477,7 +491,7 @@ class ItemImageBox extends StatelessWidget {
}
class ItemGalleryBox extends StatelessWidget {
const ItemGalleryBox(this.index);
const ItemGalleryBox(this.index, {Key key}) : super(key: key);
final int index;
......@@ -548,6 +562,8 @@ class ItemGalleryBox extends StatelessWidget {
}
class BottomBar extends StatelessWidget {
const BottomBar({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
......@@ -574,7 +590,7 @@ class BottomBar extends StatelessWidget {
}
class BottomBarButton extends StatelessWidget {
const BottomBarButton(this.icon, this.title);
const BottomBarButton(this.icon, this.title, {Key key}) : super(key: key);
final IconData icon;
final String title;
......@@ -618,7 +634,7 @@ class GalleryDrawer extends StatelessWidget {
key: const PageStorageKey<String>('gallery-drawer'),
padding: EdgeInsets.zero,
children: <Widget>[
FancyDrawerHeader(),
const FancyDrawerHeader(),
ListTile(
key: const Key('scroll-switcher'),
title: const Text('Scroll Mode'),
......@@ -668,6 +684,8 @@ class GalleryDrawer extends StatelessWidget {
}
class FancyDrawerHeader extends StatelessWidget {
const FancyDrawerHeader({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
......
......@@ -27,7 +27,7 @@ Future<void> main() async {
ready.complete();
},
behavior: HitTestBehavior.opaque,
child: IgnorePointer(
child: const IgnorePointer(
ignoring: true,
child: ComplexLayoutApp(),
),
......@@ -45,7 +45,7 @@ Future<void> main() async {
// remove onTap handler, enable pointer events for app
runApp(GestureDetector(
child: IgnorePointer(
child: const IgnorePointer(
ignoring: false,
child: ComplexLayoutApp(),
),
......
......@@ -29,7 +29,7 @@ const String kMacrobenchmarks = 'Macrobenchmarks';
void main() => runApp(const MacrobenchmarksApp());
class MacrobenchmarksApp extends StatelessWidget {
const MacrobenchmarksApp({this.initialRoute = '/'});
const MacrobenchmarksApp({Key key, this.initialRoute = '/'}) : super(key: key);
@override
Widget build(BuildContext context) {
......@@ -37,25 +37,25 @@ class MacrobenchmarksApp extends StatelessWidget {
title: kMacrobenchmarks,
initialRoute: initialRoute,
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => HomePage(),
kCullOpacityRouteName: (BuildContext context) => CullOpacityPage(),
kCubicBezierRouteName: (BuildContext context) => CubicBezierPage(),
kBackdropFilterRouteName: (BuildContext context) => BackdropFilterPage(),
kPostBackdropFilterRouteName: (BuildContext context) => PostBackdropFilterPage(),
kSimpleAnimationRouteName: (BuildContext context) => SimpleAnimationPage(),
kPictureCacheRouteName: (BuildContext context) => PictureCachePage(),
kLargeImageChangerRouteName: (BuildContext context) => LargeImageChangerPage(),
kLargeImagesRouteName: (BuildContext context) => LargeImagesPage(),
kTextRouteName: (BuildContext context) => TextPage(),
kFullscreenTextRouteName: (BuildContext context) => TextFieldPage(),
kAnimatedPlaceholderRouteName: (BuildContext context) => AnimatedPlaceholderPage(),
kColorFilterAndFadeRouteName: (BuildContext context) => ColorFilterAndFadePage(),
'/': (BuildContext context) => const HomePage(),
kCullOpacityRouteName: (BuildContext context) => const CullOpacityPage(),
kCubicBezierRouteName: (BuildContext context) => const CubicBezierPage(),
kBackdropFilterRouteName: (BuildContext context) => const BackdropFilterPage(),
kPostBackdropFilterRouteName: (BuildContext context) => const PostBackdropFilterPage(),
kSimpleAnimationRouteName: (BuildContext context) => const SimpleAnimationPage(),
kPictureCacheRouteName: (BuildContext context) => const PictureCachePage(),
kLargeImageChangerRouteName: (BuildContext context) => const LargeImageChangerPage(),
kLargeImagesRouteName: (BuildContext context) => const LargeImagesPage(),
kTextRouteName: (BuildContext context) => const TextPage(),
kFullscreenTextRouteName: (BuildContext context) => const TextFieldPage(),
kAnimatedPlaceholderRouteName: (BuildContext context) => const AnimatedPlaceholderPage(),
kColorFilterAndFadeRouteName: (BuildContext context) => const ColorFilterAndFadePage(),
kFadingChildAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.opacity),
kImageFilteredTransformAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.rotateFilter),
kMultiWidgetConstructionRouteName: (BuildContext context) => const MultiWidgetConstructTable(10, 20),
kHeavyGridViewRouteName: (BuildContext context) => HeavyGridViewPage(),
kSimpleScrollRouteName: (BuildContext context) => SimpleScroll(),
kStackSizeRouteName: (BuildContext context) => StackSizePage(),
kHeavyGridViewRouteName: (BuildContext context) => const HeavyGridViewPage(),
kSimpleScrollRouteName: (BuildContext context) => const SimpleScroll(),
kStackSizeRouteName: (BuildContext context) => const StackSizePage(),
},
);
}
......@@ -64,6 +64,8 @@ class MacrobenchmarksApp extends StatelessWidget {
}
class HomePage extends StatelessWidget {
const HomePage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
......
......@@ -24,6 +24,8 @@ const String kBlueSquare = 'iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAASEl'
/// A 10x10 grid of animated looping placeholder gifts that fade into a
/// blue square.
class AnimatedPlaceholderPage extends StatelessWidget {
const AnimatedPlaceholderPage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return GridView.builder(
......
......@@ -7,6 +7,8 @@ import 'dart:ui';
import 'package:flutter/material.dart';
class BackdropFilterPage extends StatefulWidget {
const BackdropFilterPage({Key key}) : super(key: key);
@override
_BackdropFilterPageState createState() => _BackdropFilterPageState();
}
......
......@@ -9,6 +9,8 @@ import 'package:flutter/material.dart';
// This tests whether the Opacity layer raster cache works with color filters.
// See https://github.com/flutter/flutter/issues/51975.
class ColorFilterAndFadePage extends StatefulWidget {
const ColorFilterAndFadePage({Key key}) : super(key: key);
@override
_ColorFilterAndFadePageState createState() => _ColorFilterAndFadePageState();
}
......
......@@ -8,6 +8,8 @@ import 'package:flutter/material.dart';
// Based on https://github.com/eseidelGoogle/bezier_perf/blob/master/lib/main.dart
class CubicBezierPage extends StatelessWidget {
const CubicBezierPage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Center(
......@@ -22,7 +24,7 @@ class CubicBezierPage extends StatelessWidget {
}
class Bezier extends StatelessWidget {
const Bezier(this.color, this.scale, {this.blur = 0.0, this.delay = 0.0});
const Bezier(this.color, this.scale, {Key key, this.blur = 0.0, this.delay = 0.0}) : super(key: key);
final Color color;
final double scale;
......@@ -91,7 +93,7 @@ class PathDetail {
}
class AnimatedBezier extends StatefulWidget {
const AnimatedBezier(this.color, this.scale, {this.blur = 0.0, this.delay});
const AnimatedBezier(this.color, this.scale, {Key key, this.blur = 0.0, this.delay}) : super(key: key);
final Color color;
final double scale;
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class CullOpacityPage extends StatefulWidget {
const CullOpacityPage({Key key}) : super(key: key);
@override
State<StatefulWidget> createState() => _CullOpacityPageState();
}
......
......@@ -12,10 +12,11 @@ enum FilterType {
}
class FilteredChildAnimationPage extends StatefulWidget {
const FilteredChildAnimationPage(this.initialFilterType, [
const FilteredChildAnimationPage(this.initialFilterType, {
Key key,
this.initialComplexChild = true,
this.initialUseRepaintBoundary = true,
]);
}) : super(key: key);
final FilterType initialFilterType;
final bool initialComplexChild;
......
......@@ -48,6 +48,8 @@ const String textLotsOfText = 'Lorem ipsum dolor sit amet, consectetur '
'🦻 👃 🫀 🫁 🧠 🦷 🦴 👀 👁 👅 👄 💋 🩸';
class TextFieldPage extends StatelessWidget {
const TextFieldPage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Material(
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class HeavyGridViewPage extends StatelessWidget {
const HeavyGridViewPage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return GridView.builder(
......
......@@ -8,6 +8,8 @@ import 'package:flutter/material.dart';
/// Displays a new (from image cache's perspective) large image every 500ms.
class LargeImageChangerPage extends StatefulWidget {
const LargeImageChangerPage({Key key}) : super(key: key);
@override
_LargeImageChangerState createState() => _LargeImageChangerState();
}
......
......@@ -7,6 +7,8 @@ import 'dart:typed_data';
import 'package:flutter/material.dart';
class LargeImagesPage extends StatelessWidget {
const LargeImagesPage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
final ImageCache imageCache = PaintingBinding.instance.imageCache;
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class PictureCachePage extends StatelessWidget {
const PictureCachePage({Key key}) : super(key: key);
static const List<String> kTabNames = <String>['1', '2', '3', '4', '5'];
@override
......
......@@ -7,6 +7,8 @@ import 'dart:ui';
import 'package:flutter/material.dart';
class PostBackdropFilterPage extends StatefulWidget {
const PostBackdropFilterPage({Key key}) : super(key: key);
@override
_PostBackdropFilterPageState createState() => _PostBackdropFilterPageState();
}
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class SimpleAnimationPage extends StatelessWidget {
const SimpleAnimationPage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Center(child: LinearProgressIndicator());
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class SimpleScroll extends StatelessWidget {
const SimpleScroll({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ListView(
......
......@@ -81,6 +81,8 @@ final GetStackPointerCallback getStackPointer = () {
}();
class StackSizePage extends StatelessWidget {
const StackSizePage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Material(
......@@ -89,7 +91,7 @@ class StackSizePage extends StatelessWidget {
Container(
width: 200,
height: 100,
child: ParentWidget(),
child: const ParentWidget(),
),
],
),
......@@ -98,6 +100,8 @@ class StackSizePage extends StatelessWidget {
}
class ParentWidget extends StatelessWidget {
const ParentWidget({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
final int myStackSize = getStackPointer();
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class TextPage extends StatelessWidget {
const TextPage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Material(
......
......@@ -271,7 +271,7 @@ class BenchBuildColorsGrid extends WidgetBuildRecorder {
@override
Widget createWidget() {
_counter++;
return MaterialApp(home: ColorsDemo());
return const MaterialApp(home: ColorsDemo());
}
}
......@@ -469,6 +469,8 @@ class PaletteTabView extends StatelessWidget {
}
class ColorsDemo extends StatelessWidget {
const ColorsDemo({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return DefaultTabController(
......
......@@ -84,7 +84,7 @@ class _MyHomePageState extends State<MyHomePage> {
}
class ProductPreview extends StatelessWidget {
const ProductPreview(this.previewIndex);
const ProductPreview(this.previewIndex, {Key key}) : super(key: key);
final int previewIndex;
......
......@@ -17,7 +17,7 @@ void main() {
testWidgets(
'Frame Counter and Input Delay for benchmarkLive',
(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: Scaffold(body: SimpleScroll())));
await tester.pumpWidget(const MaterialApp(home: Scaffold(body: SimpleScroll())));
await tester.pumpAndSettle();
final Offset location = tester.getCenter(find.byType(ListView));
int frameCount = 0;
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class ButtonMatrixApp extends StatefulWidget {
const ButtonMatrixApp({Key key}) : super(key: key);
@override
ButtonMatrixAppState createState() => ButtonMatrixAppState();
}
......@@ -48,5 +50,5 @@ class ButtonMatrixAppState extends State<ButtonMatrixApp> {
}
void main() {
runApp(ButtonMatrixApp());
runApp(const ButtonMatrixApp());
}
......@@ -13,7 +13,7 @@ void topMain() => runApp(const MyApp(Colors.green));
void bottomMain() => runApp(const MyApp(Colors.purple));
class MyApp extends StatelessWidget {
const MyApp(this.color);
const MyApp(this.color, {Key key}) : super(key: key);
final Color color;
......
......@@ -20,6 +20,8 @@ import 'stock_symbol_viewer.dart';
import 'stock_types.dart';
class StocksApp extends StatefulWidget {
const StocksApp({Key key}) : super(key: key);
@override
StocksAppState createState() => StocksAppState();
}
......@@ -109,5 +111,5 @@ class StocksAppState extends State<StocksApp> {
}
void main() {
runApp(StocksApp());
runApp(const StocksApp());
}
......@@ -52,7 +52,7 @@ class _NotImplementedDialog extends StatelessWidget {
}
class StockHome extends StatefulWidget {
const StockHome(this.stocks, this.configuration, this.updater);
const StockHome(this.stocks, this.configuration, this.updater, {Key key}) : super(key: key);
final StockData stocks;
final StockConfiguration configuration;
......
......@@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
import 'stock_types.dart';
class StockSettings extends StatefulWidget {
const StockSettings(this.configuration, this.updater);
const StockSettings(this.configuration, this.updater, {Key key}) : super(key: key);
final StockConfiguration configuration;
final ValueChanged<StockConfiguration> updater;
......
......@@ -65,7 +65,7 @@ class _StockSymbolView extends StatelessWidget {
}
class StockSymbolPage extends StatelessWidget {
const StockSymbolPage({ this.symbol, this.stocks });
const StockSymbolPage({ Key key, this.symbol, this.stocks }) : super(key: key);
final String symbol;
final StockData stocks;
......@@ -113,7 +113,7 @@ class StockSymbolPage extends StatelessWidget {
}
class StockSymbolBottomSheet extends StatelessWidget {
const StockSymbolBottomSheet({ this.stock });
const StockSymbolBottomSheet({ Key key, this.stock }) : super(key: key);
final Stock stock;
......
......@@ -9,11 +9,13 @@ Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
const MethodChannel channel = MethodChannel('com.example.abstract_method_smoke_test');
await channel.invokeMethod<void>('show_keyboard');
runApp(MyApp());
runApp(const MyApp());
print('Test suceeded');
}
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
......@@ -21,12 +23,14 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(),
home: const HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key key}) : super(key: key);
@override
_HomePage createState() => _HomePage();
}
......@@ -40,7 +44,7 @@ class _HomePage extends State<HomePage> {
// https://github.com/flutter/flutter/issues/40126
WidgetsBinding.instance.addPostFrameCallback((_) async {
Navigator.of(context).push(
MaterialPageRoute<void>(builder: (_) => SecondPage()));
MaterialPageRoute<void>(builder: (_) => const SecondPage()));
});
}
......@@ -51,6 +55,8 @@ class _HomePage extends State<HomePage> {
}
class SecondPage extends StatelessWidget {
const SecondPage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
......
......@@ -43,14 +43,14 @@ Future<String> dataHandler(String message) async {
}
Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
selectionControlsRoute : (BuildContext context) => SelectionControlsPage(),
popupControlsRoute : (BuildContext context) => PopupControlsPage(),
textFieldRoute : (BuildContext context) => TextFieldPage(),
headingsRoute: (BuildContext context) => HeadingsPage(),
selectionControlsRoute : (BuildContext context) => const SelectionControlsPage(),
popupControlsRoute : (BuildContext context) => const PopupControlsPage(),
textFieldRoute : (BuildContext context) => const TextFieldPage(),
headingsRoute: (BuildContext context) => const HeadingsPage(),
};
class TestApp extends StatelessWidget {
const TestApp();
const TestApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
......
......@@ -9,6 +9,8 @@ export 'controls_constants.dart';
/// A test page with a checkbox, three radio buttons, and a switch.
class SelectionControlsPage extends StatefulWidget {
const SelectionControlsPage({Key key}) : super(key: key);
@override
State<StatefulWidget> createState() => _SelectionControlsPageState();
}
......
......@@ -9,6 +9,8 @@ export 'headings_constants.dart';
/// A test page with an app bar and some body text for testing heading flags.
class HeadingsPage extends StatelessWidget {
const HeadingsPage({Key key}) : super(key: key);
static const ValueKey<String> _appBarTitleKey = ValueKey<String>(appBarTitleKeyValue);
static const ValueKey<String> _bodyTextKey = ValueKey<String>(bodyTextKeyValue);
......
......@@ -10,6 +10,8 @@ export 'popup_constants.dart';
/// A page with a popup menu, a dropdown menu, and a modal alert.
class PopupControlsPage extends StatefulWidget {
const PopupControlsPage({Key key}) : super(key: key);
@override
State<StatefulWidget> createState() => _PopupControlsPageState();
}
......
......@@ -10,6 +10,8 @@ export 'text_field_constants.dart';
/// A page with a normal text field and a password field.
class TextFieldPage extends StatefulWidget {
const TextFieldPage({Key key}) : super(key: key);
@override
State<StatefulWidget> createState() => _TextFieldPageState();
}
......
......@@ -16,10 +16,12 @@ final List<PageWidget> _allPages = <PageWidget>[
void main() {
enableFlutterDriverExtension(handler: driverDataHandler.handleMessage);
runApp(MaterialApp(home: Home()));
runApp(const MaterialApp(home: Home()));
}
class Home extends StatelessWidget {
const Home({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
......
......@@ -18,12 +18,12 @@ MethodChannel channel = const MethodChannel('android_views_integration');
const String kEventsFileName = 'touchEvents';
class MotionEventsPage extends PageWidget {
const MotionEventsPage()
: super('Motion Event Tests', const ValueKey<String>('MotionEventsListTile'));
const MotionEventsPage({Key key})
: super('Motion Event Tests', const ValueKey<String>('MotionEventsListTile'), key: key);
@override
Widget build(BuildContext context) {
return MotionEventsBody();
return const MotionEventsBody();
}
}
......@@ -44,6 +44,8 @@ class FutureDataHandler {
FutureDataHandler driverDataHandler = FutureDataHandler();
class MotionEventsBody extends StatefulWidget {
const MotionEventsBody({Key key}) : super(key: key);
@override
State createState() => MotionEventsBodyState();
}
......@@ -251,7 +253,7 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
}
class TouchEventDiff extends StatelessWidget {
const TouchEventDiff(this.originalEvent, this.synthesizedEvent);
const TouchEventDiff(this.originalEvent, this.synthesizedEvent, {Key key}) : super(key: key);
final Map<String, dynamic> originalEvent;
final Map<String, dynamic> synthesizedEvent;
......
......@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
//
/// A testing page has to override this in order to be put as one of the items in the main page.
abstract class PageWidget extends StatelessWidget {
const PageWidget(this.title, this.tileKey);
const PageWidget(this.title, this.tileKey, {Key key}) : super(key: key);
/// The title of the testing page
///
......
......@@ -10,14 +10,16 @@ import 'package:flutter/services.dart';
import 'page.dart';
class WindowManagerIntegrationsPage extends PageWidget {
const WindowManagerIntegrationsPage()
: super('Window Manager Integrations Tests', const ValueKey<String>('WmIntegrationsListTile'));
const WindowManagerIntegrationsPage({Key key})
: super('Window Manager Integrations Tests', const ValueKey<String>('WmIntegrationsListTile'), key: key);
@override
Widget build(BuildContext context) => WindowManagerBody();
Widget build(BuildContext context) => const WindowManagerBody();
}
class WindowManagerBody extends StatefulWidget {
const WindowManagerBody({Key key}) : super(key: key);
@override
State<WindowManagerBody> createState() => WindowManagerBodyState();
}
......
......@@ -15,10 +15,12 @@ import 'src/test_step.dart';
void main() {
enableFlutterDriverExtension();
runApp(TestApp());
runApp(const TestApp());
}
class TestApp extends StatefulWidget {
const TestApp({Key key}) : super(key: key);
@override
_TestAppState createState() => _TestAppState();
}
......
......@@ -11,10 +11,12 @@ import 'package:flutter_driver/driver_extension.dart';
void main() {
enableFlutterDriverExtension();
debugPrint('Application starting...');
runApp(MyApp());
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key key}) : super(key: key);
@override
State createState() => MyAppState();
}
......
......@@ -8,10 +8,12 @@ import 'package:flutter_driver/driver_extension.dart';
void main() {
enableFlutterDriverExtension();
runApp(Center(child: Flavor()));
runApp(const Center(child: Flavor()));
}
class Flavor extends StatefulWidget {
const Flavor({Key key}) : super(key: key);
@override
_FlavorState createState() => _FlavorState();
}
......
......@@ -138,7 +138,7 @@ class _CalculatorState extends State<Calculator> {
}
class CalcDisplay extends StatelessWidget {
const CalcDisplay({ this.content });
const CalcDisplay({ Key? key, this.content}) : super(key: key);
final String? content;
......@@ -154,7 +154,7 @@ class CalcDisplay extends StatelessWidget {
}
class KeyPad extends StatelessWidget {
const KeyPad({ this.calcState });
const KeyPad({ Key? key, this.calcState }) : super(key: key);
final _CalculatorState? calcState;
......@@ -222,7 +222,7 @@ class KeyPad extends StatelessWidget {
}
class KeyRow extends StatelessWidget {
const KeyRow(this.keys);
const KeyRow(this.keys, {Key? key}) : super(key: key);
final List<Widget> keys;
......@@ -238,7 +238,7 @@ class KeyRow extends StatelessWidget {
}
class CalcKey extends StatelessWidget {
const CalcKey(this.text, this.onTap);
const CalcKey(this.text, this.onTap, {Key? key}) : super(key: key);
final String text;
final GestureTapCallback onTap;
......@@ -265,8 +265,8 @@ class CalcKey extends StatelessWidget {
}
class NumberKey extends CalcKey {
NumberKey(int value, _CalculatorState? calcState)
NumberKey(int value, _CalculatorState? calcState, {Key? key})
: super('$value', () {
calcState!.handleNumberTap(value);
});
}, key: key);
}
......@@ -120,6 +120,8 @@ class PaletteTabView extends StatelessWidget {
}
class ColorsDemo extends StatelessWidget {
const ColorsDemo({Key? key}) : super(key: key);
static const String routeName = '/colors';
@override
......
......@@ -86,6 +86,8 @@ class _ContactItem extends StatelessWidget {
}
class ContactsDemo extends StatefulWidget {
const ContactsDemo({Key? key}) : super(key: key);
static const String routeName = '/contacts';
@override
......
......@@ -7,6 +7,8 @@ import 'package:flutter/cupertino.dart';
import '../../gallery/demo.dart';
class CupertinoProgressIndicatorDemo extends StatelessWidget {
const CupertinoProgressIndicatorDemo({Key? key}) : super(key: key);
static const String routeName = '/cupertino/progress_indicator';
@override
......
......@@ -7,6 +7,8 @@ import 'package:flutter/cupertino.dart';
import '../../gallery/demo.dart';
class CupertinoAlertDemo extends StatefulWidget {
const CupertinoAlertDemo({Key? key}) : super(key: key);
static const String routeName = '/cupertino/alert';
@override
......
......@@ -7,6 +7,8 @@ import 'package:flutter/cupertino.dart';
import '../../gallery/demo.dart';
class CupertinoButtonsDemo extends StatefulWidget {
const CupertinoButtonsDemo({Key? key}) : super(key: key);
static const String routeName = '/cupertino/buttons';
@override
......
......@@ -32,13 +32,14 @@ const List<String> coolColorNames = <String>[
const int _kChildCount = 50;
class CupertinoNavigationDemo extends StatelessWidget {
CupertinoNavigationDemo({ this.randomSeed })
CupertinoNavigationDemo({ Key? key, this.randomSeed })
: colorItems = List<Color>.generate(_kChildCount, (int index) {
return coolColors[math.Random(randomSeed).nextInt(coolColors.length)];
}) ,
colorNameItems = List<String>.generate(_kChildCount, (int index) {
return coolColorNames[math.Random(randomSeed).nextInt(coolColorNames.length)];
});
}),
super(key: key);
static const String routeName = '/cupertino/navigation';
......@@ -85,12 +86,12 @@ class CupertinoNavigationDemo extends StatelessWidget {
);
case 1:
return CupertinoTabView(
builder: (BuildContext context) => CupertinoDemoTab2(),
builder: (BuildContext context) => const CupertinoDemoTab2(),
defaultTitle: 'Support Chat',
);
case 2:
return CupertinoTabView(
builder: (BuildContext context) => CupertinoDemoTab3(),
builder: (BuildContext context) => const CupertinoDemoTab3(),
defaultTitle: 'Account',
);
}
......@@ -104,7 +105,7 @@ class CupertinoNavigationDemo extends StatelessWidget {
}
class ExitButton extends StatelessWidget {
const ExitButton();
const ExitButton({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
......@@ -134,10 +135,11 @@ final Widget trailingButtons = Row(
class CupertinoDemoTab1 extends StatelessWidget {
const CupertinoDemoTab1({
Key? key,
this.colorItems,
this.colorNameItems,
this.randomSeed,
});
}) : super(key: key);
final List<Color>? colorItems;
final List<String>? colorNameItems;
......@@ -184,12 +186,13 @@ class CupertinoDemoTab1 extends StatelessWidget {
class Tab1RowItem extends StatelessWidget {
const Tab1RowItem({
Key? key,
this.index,
this.lastItem,
this.color,
this.colorName,
this.randomSeed,
});
}) : super(key: key);
final int? index;
final bool? lastItem;
......@@ -287,7 +290,7 @@ class Tab1RowItem extends StatelessWidget {
}
class Tab1ItemPage extends StatefulWidget {
const Tab1ItemPage({this.color, this.colorName, this.index, this.randomSeed});
const Tab1ItemPage({Key? key, this.color, this.colorName, this.index, this.randomSeed}) : super(key: key);
final Color? color;
final String? colorName;
......@@ -441,6 +444,8 @@ class Tab1ItemPageState extends State<Tab1ItemPage> {
}
class CupertinoDemoTab2 extends StatelessWidget {
const CupertinoDemoTab2({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
......@@ -450,7 +455,7 @@ class CupertinoDemoTab2 extends StatelessWidget {
child: CupertinoScrollbar(
child: ListView(
children: <Widget>[
CupertinoUserInterfaceLevel(
const CupertinoUserInterfaceLevel(
data: CupertinoUserInterfaceLevelData.elevated,
child: Tab2Header(),
),
......@@ -463,6 +468,8 @@ class CupertinoDemoTab2 extends StatelessWidget {
}
class Tab2Header extends StatelessWidget {
const Tab2Header({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
......@@ -589,7 +596,7 @@ enum Tab2ConversationBubbleColor {
}
class Tab2ConversationBubble extends StatelessWidget {
const Tab2ConversationBubble({this.text, this.color});
const Tab2ConversationBubble({Key? key, this.text, this.color}) : super(key: key);
final String? text;
final Tab2ConversationBubbleColor? color;
......@@ -633,7 +640,7 @@ class Tab2ConversationBubble extends StatelessWidget {
}
class Tab2ConversationAvatar extends StatelessWidget {
const Tab2ConversationAvatar({this.text, this.color});
const Tab2ConversationAvatar({Key? key, this.text, this.color}) : super(key: key);
final String? text;
final Color? color;
......@@ -672,7 +679,7 @@ class Tab2ConversationAvatar extends StatelessWidget {
}
class Tab2ConversationRow extends StatelessWidget {
const Tab2ConversationRow({this.avatar, this.text});
const Tab2ConversationRow({Key? key, this.avatar, this.text}) : super(key: key);
final Tab2ConversationAvatar? avatar;
final String? text;
......@@ -742,6 +749,8 @@ List<Widget> buildTab2Conversation() {
}
class CupertinoDemoTab3 extends StatelessWidget {
const CupertinoDemoTab3({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
......@@ -755,7 +764,7 @@ class CupertinoDemoTab3 extends StatelessWidget {
Navigator.of(context, rootNavigator: true).push(
CupertinoPageRoute<bool>(
fullscreenDialog: true,
builder: (BuildContext context) => Tab3Dialog(),
builder: (BuildContext context) => const Tab3Dialog(),
),
);
},
......@@ -792,6 +801,8 @@ class CupertinoDemoTab3 extends StatelessWidget {
}
class Tab3Dialog extends StatelessWidget {
const Tab3Dialog({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
......
......@@ -12,6 +12,8 @@ const double _kPickerSheetHeight = 216.0;
const double _kPickerItemHeight = 32.0;
class CupertinoPickerDemo extends StatefulWidget {
const CupertinoPickerDemo({Key? key}) : super(key: key);
static const String routeName = '/cupertino/picker';
@override
......
......@@ -9,6 +9,8 @@ import 'package:flutter/cupertino.dart';
import '../../gallery/demo.dart';
class CupertinoRefreshControlDemo extends StatefulWidget {
const CupertinoRefreshControlDemo({Key? key}) : super(key: key);
static const String routeName = '/cupertino/refresh';
@override
......
......@@ -12,6 +12,8 @@ const Color _kKeyPenumbraOpacity = Color(0x24000000); // alpha = 0.14
const Color _kAmbientShadowOpacity = Color(0x1F000000); // alpha = 0.12
class CupertinoSegmentedControlDemo extends StatefulWidget {
const CupertinoSegmentedControlDemo({Key? key}) : super(key: key);
static const String routeName = 'cupertino/segmented_control';
@override
......
......@@ -7,6 +7,8 @@ import 'package:flutter/cupertino.dart';
import '../../gallery/demo.dart';
class CupertinoSliderDemo extends StatefulWidget {
const CupertinoSliderDemo({Key? key}) : super(key: key);
static const String routeName = '/cupertino/slider';
@override
......
......@@ -7,6 +7,8 @@ import 'package:flutter/cupertino.dart';
import '../../gallery/demo.dart';
class CupertinoSwitchDemo extends StatefulWidget {
const CupertinoSwitchDemo({Key? key}) : super(key: key);
static const String routeName = '/cupertino/switch';
@override
......
......@@ -5,6 +5,8 @@
import 'package:flutter/cupertino.dart';
class CupertinoTextFieldDemo extends StatefulWidget {
const CupertinoTextFieldDemo({Key? key}) : super(key: key);
static const String routeName = '/cupertino/text_fields';
@override
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class FortnightlyDemo extends StatelessWidget {
const FortnightlyDemo({Key? key}) : super(key: key);
static const String routeName = '/fortnightly';
@override
......@@ -15,7 +17,7 @@ class FortnightlyDemo extends StatelessWidget {
home: Scaffold(
body: Stack(
children: <Widget>[
FruitPage(),
const FruitPage(),
SafeArea(
child: ShortAppBar(
onBackPressed: () {
......@@ -31,7 +33,7 @@ class FortnightlyDemo extends StatelessWidget {
}
class ShortAppBar extends StatelessWidget {
const ShortAppBar({ this.onBackPressed });
const ShortAppBar({ Key? key, this.onBackPressed }) : super(key: key);
final VoidCallback? onBackPressed;
......@@ -66,6 +68,8 @@ class ShortAppBar extends StatelessWidget {
}
class FruitPage extends StatelessWidget {
const FruitPage({Key? key}) : super(key: key);
static final String paragraph1 = '''
Have you ever held a quince? It's strange;
covered in a fuzz somewhere between peach skin and a spider web. And it's
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import '../gallery/demo.dart';
class ImagesDemo extends StatelessWidget {
const ImagesDemo({Key? key}) : super(key: key);
static const String routeName = '/images';
@override
......
......@@ -239,6 +239,8 @@ class BackdropTitle extends AnimatedWidget {
// This widget is essentially the backdrop itself.
class BackdropDemo extends StatefulWidget {
const BackdropDemo({Key? key}) : super(key: key);
static const String routeName = '/material/backdrop';
@override
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import '../../gallery/demo.dart';
class BottomAppBarDemo extends StatefulWidget {
const BottomAppBarDemo({Key? key}) : super(key: key);
static const String routeName = '/material/bottom_app_bar';
@override
......
......@@ -74,6 +74,8 @@ class NavigationIconView {
}
class CustomIcon extends StatelessWidget {
const CustomIcon({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final IconThemeData iconTheme = IconTheme.of(context);
......@@ -87,6 +89,8 @@ class CustomIcon extends StatelessWidget {
}
class CustomInactiveIcon extends StatelessWidget {
const CustomInactiveIcon({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final IconThemeData iconTheme = IconTheme.of(context);
......@@ -102,6 +106,8 @@ class CustomInactiveIcon extends StatelessWidget {
}
class BottomNavigationDemo extends StatefulWidget {
const BottomNavigationDemo({Key? key}) : super(key: key);
static const String routeName = '/material/bottom_navigation';
@override
......@@ -125,8 +131,8 @@ class _BottomNavigationDemoState extends State<BottomNavigationDemo>
vsync: this,
),
NavigationIconView(
activeIcon: CustomIcon(),
icon: CustomInactiveIcon(),
activeIcon: const CustomIcon(),
icon: const CustomInactiveIcon(),
title: 'Box',
color: Colors.deepOrange,
vsync: this,
......
......@@ -46,6 +46,8 @@ const String _actionText =
const String _actionCode = 'buttons_action';
class ButtonsDemo extends StatefulWidget {
const ButtonsDemo({Key? key}) : super(key: key);
static const String routeName = '/material/buttons';
@override
......
......@@ -335,6 +335,8 @@ class TravelDestinationContent extends StatelessWidget {
}
class CardsDemo extends StatefulWidget {
const CardsDemo({Key? key}) : super(key: key);
static const String routeName = '/material/cards';
@override
......
......@@ -135,6 +135,8 @@ class _ChipsTile extends StatelessWidget {
}
class ChipDemo extends StatefulWidget {
const ChipDemo({Key? key}) : super(key: key);
static const String routeName = '/material/chip';
@override
......
......@@ -142,6 +142,8 @@ class DessertDataSource extends DataTableSource {
}
class DataTableDemo extends StatefulWidget {
const DataTableDemo({Key? key}) : super(key: key);
static const String routeName = '/material/data-table';
@override
......
......@@ -113,6 +113,8 @@ class _DateTimePicker extends StatelessWidget {
}
class DateAndTimePickerDemo extends StatefulWidget {
const DateAndTimePickerDemo({Key? key}) : super(key: key);
static const String routeName = '/material/date-and-time-pickers';
@override
......
......@@ -48,6 +48,8 @@ class DialogDemoItem extends StatelessWidget {
}
class DialogDemo extends StatefulWidget {
const DialogDemo({Key? key}) : super(key: key);
static const String routeName = '/material/dialog';
@override
......@@ -192,7 +194,7 @@ class DialogDemoState extends State<DialogDemo> {
child: const Text('FULLSCREEN'),
onPressed: () {
Navigator.push(context, MaterialPageRoute<DismissDialogAction>(
builder: (BuildContext context) => FullScreenDialogDemo(),
builder: (BuildContext context) => const FullScreenDialogDemo(),
fullscreenDialog: true,
));
},
......
......@@ -13,6 +13,8 @@ const String _kAsset2 = 'people/square/sandra.png';
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
class DrawerDemo extends StatefulWidget {
const DrawerDemo({Key? key}) : super(key: key);
static const String routeName = '/material/drawer';
@override
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import '../../gallery/demo.dart';
class ElevationDemo extends StatefulWidget {
const ElevationDemo({Key? key}) : super(key: key);
static const String routeName = '/material/elevation';
@override
......
......@@ -18,11 +18,12 @@ typedef ValueToString<T> = String? Function(T value);
class DualHeaderWithHint extends StatelessWidget {
const DualHeaderWithHint({
Key? key,
this.name,
this.value,
this.hint,
this.showHint,
});
}) : super(key: key);
final String? name;
final String? value;
......@@ -80,11 +81,12 @@ class DualHeaderWithHint extends StatelessWidget {
class CollapsibleBody extends StatelessWidget {
const CollapsibleBody({
Key? key,
this.margin = EdgeInsets.zero,
this.child,
this.onSave,
this.onCancel,
});
}) : super(key: key);
final EdgeInsets margin;
final Widget? child;
......@@ -175,6 +177,8 @@ class DemoItem<T> {
}
class ExpansionPanelsDemo extends StatefulWidget {
const ExpansionPanelsDemo({Key? key}) : super(key: key);
static const String routeName = '/material/expansion_panels';
@override
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import '../../gallery/demo.dart';
class ExpansionTileListDemo extends StatelessWidget {
const ExpansionTileListDemo({Key? key}) : super(key: key);
static const String routeName = '/material/expansion-tile-list';
@override
......
......@@ -93,6 +93,8 @@ class DateTimeItem extends StatelessWidget {
}
class FullScreenDialogDemo extends StatefulWidget {
const FullScreenDialogDemo({Key? key}) : super(key: key);
@override
FullScreenDialogDemoState createState() => FullScreenDialogDemoState();
}
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import '../../gallery/demo.dart';
class IconsDemo extends StatefulWidget {
const IconsDemo({Key? key}) : super(key: key);
static const String routeName = '/material/icons';
@override
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import '../../gallery/demo.dart';
class ModalBottomSheetDemo extends StatelessWidget {
const ModalBottomSheetDemo({Key? key}) : super(key: key);
static const String routeName = '/material/modal-bottom-sheet';
@override
......
......@@ -74,6 +74,8 @@ class _PageSelector extends StatelessWidget {
}
class PageSelectorDemo extends StatelessWidget {
const PageSelectorDemo({Key? key}) : super(key: key);
static const String routeName = '/material/page-selector';
static final List<Icon> icons = <Icon>[
const Icon(Icons.event, semanticLabel: 'Event'),
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import '../../gallery/demo.dart';
class PersistentBottomSheetDemo extends StatefulWidget {
const PersistentBottomSheetDemo({Key? key}) : super(key: key);
static const String routeName = '/material/persistent-bottom-sheet';
@override
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import '../../gallery/demo.dart';
class ProgressIndicatorDemo extends StatefulWidget {
const ProgressIndicatorDemo({Key? key}) : super(key: key);
static const String routeName = '/material/progress-indicator';
@override
......
......@@ -36,6 +36,8 @@ const List<_Page> _allPages = <_Page>[
];
class ScrollableTabsDemo extends StatefulWidget {
const ScrollableTabsDemo({Key? key}) : super(key: key);
static const String routeName = '/material/scrollable-tabs';
@override
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import '../../gallery/demo.dart';
class SearchDemo extends StatefulWidget {
const SearchDemo({Key? key}) : super(key: key);
static const String routeName = '/material/search';
@override
......
......@@ -28,6 +28,8 @@ const String _switchText =
const String _switchCode = 'selectioncontrols_switch';
class SelectionControlsDemo extends StatefulWidget {
const SelectionControlsDemo({Key? key}) : super(key: key);
static const String routeName = '/material/selection-controls';
@override
......
......@@ -9,6 +9,8 @@ import 'package:flutter/material.dart';
import '../../gallery/demo.dart';
class SliderDemo extends StatefulWidget {
const SliderDemo({Key? key}) : super(key: key);
static const String routeName = '/material/slider';
@override
......
......@@ -138,6 +138,8 @@ class _CardDataItem extends StatelessWidget {
}
class TabsDemo extends StatelessWidget {
const TabsDemo({Key? key}) : super(key: key);
static const String routeName = '/material/tabs';
@override
......
......@@ -35,6 +35,8 @@ final List<_Page> _allPages = <_Page>[
];
class TabsFabDemo extends StatefulWidget {
const TabsFabDemo({Key? key}) : super(key: key);
static const String routeName = '/material/tabs-fab';
@override
......
......@@ -26,6 +26,7 @@ class PersonData {
class PasswordField extends StatefulWidget {
const PasswordField({
Key? key,
this.fieldKey,
this.hintText,
this.labelText,
......@@ -33,7 +34,7 @@ class PasswordField extends StatefulWidget {
this.onSaved,
this.validator,
this.onFieldSubmitted,
});
}) : super(key: key);
final Key? fieldKey;
final String? hintText;
......
......@@ -12,6 +12,7 @@ const String _introText =
'apps accessible, like screen readers.';
class TooltipDemo extends StatelessWidget {
const TooltipDemo({Key? key}) : super(key: key);
static const String routeName = '/material/tooltips';
......
......@@ -10,7 +10,7 @@ class PestoDemo extends StatelessWidget {
static const String routeName = '/pesto';
@override
Widget build(BuildContext context) => PestoHome();
Widget build(BuildContext context) => const PestoHome();
}
......@@ -29,6 +29,8 @@ final ThemeData _kTheme = ThemeData(
);
class PestoHome extends StatelessWidget {
const PestoHome({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const RecipeGridPage(recipes: kPestoRecipes);
......@@ -36,6 +38,8 @@ class PestoHome extends StatelessWidget {
}
class PestoFavorites extends StatelessWidget {
const PestoFavorites({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return RecipeGridPage(recipes: _favoriteRecipes.toList());
......@@ -167,7 +171,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
void showFavoritesPage(BuildContext context) {
Navigator.push(context, MaterialPageRoute<void>(
settings: const RouteSettings(name: '/pesto/favorites'),
builder: (BuildContext context) => PestoFavorites(),
builder: (BuildContext context) => const PestoFavorites(),
));
}
......@@ -185,7 +189,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
}
class PestoLogo extends StatefulWidget {
const PestoLogo({this.height, this.t});
const PestoLogo({Key? key, this.height, this.t}) : super(key: key);
final double? height;
final double? t;
......
......@@ -13,6 +13,8 @@ import 'package:flutter_gallery/demo/shrine/login.dart';
import 'package:flutter_gallery/demo/shrine/supplemental/cut_corners_border.dart';
class ShrineApp extends StatefulWidget {
const ShrineApp({Key? key}) : super(key: key);
@override
_ShrineAppState createState() => _ShrineAppState();
}
......@@ -62,7 +64,7 @@ Route<dynamic>? _getRoute(RouteSettings settings) {
return MaterialPageRoute<void>(
settings: settings,
builder: (BuildContext context) => LoginPage(),
builder: (BuildContext context) => const LoginPage(),
fullscreenDialog: true,
);
}
......
......@@ -198,12 +198,13 @@ class _BackdropTitle extends AnimatedWidget {
/// front or back layer is showing.
class Backdrop extends StatefulWidget {
const Backdrop({
Key? key,
required this.frontLayer,
required this.backLayer,
required this.frontTitle,
required this.backTitle,
required this.controller,
});
}) : super(key: key);
final Widget frontLayer;
final Widget backLayer;
......@@ -355,7 +356,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
onPressed: () {
Navigator.push<void>(
context,
MaterialPageRoute<void>(builder: (BuildContext context) => LoginPage()),
MaterialPageRoute<void>(builder: (BuildContext context) => const LoginPage()),
);
},
),
......@@ -364,7 +365,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
onPressed: () {
Navigator.push<void>(
context,
MaterialPageRoute<void>(builder: (BuildContext context) => LoginPage()),
MaterialPageRoute<void>(builder: (BuildContext context) => const LoginPage()),
);
},
),
......
......@@ -286,9 +286,9 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker
width: numProducts > 3 ? _width - 94.0 : _width - 64.0,
height: _kCartHeight,
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: ProductThumbnailRow(),
child: const ProductThumbnailRow(),
),
ExtraProductsNumber(),
const ExtraProductsNumber(),
],
),
],
......@@ -300,7 +300,7 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker
Widget _buildShoppingCartPage() {
return Opacity(
opacity: _cartOpacityAnimation.value,
child: ShoppingCartPage(),
child: const ShoppingCartPage(),
);
}
......@@ -404,6 +404,8 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker
}
class ProductThumbnailRow extends StatefulWidget {
const ProductThumbnailRow({Key? key}) : super(key: key);
@override
_ProductThumbnailRowState createState() => _ProductThumbnailRowState();
}
......@@ -511,6 +513,8 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> {
}
class ExtraProductsNumber extends StatelessWidget {
const ExtraProductsNumber({Key? key}) : super(key: key);
// Calculates the number to be displayed at the end of the row if there are
// more than three products in the cart. This calculates overflow products,
// including their duplicates (but not duplicates of products shown as
......@@ -554,7 +558,7 @@ class ExtraProductsNumber extends StatelessWidget {
}
class ProductThumbnail extends StatelessWidget {
const ProductThumbnail(this.animation, this.opacityAnimation, this.product);
const ProductThumbnail(this.animation, this.opacityAnimation, this.product, {Key? key}) : super(key: key);
final Animation<double> animation;
final Animation<double> opacityAnimation;
......
......@@ -12,7 +12,7 @@ import 'package:flutter_gallery/demo/shrine/model/product.dart';
import 'package:flutter_gallery/demo/shrine/supplemental/asymmetric_view.dart';
class ProductPage extends StatelessWidget {
const ProductPage({this.category = Category.all});
const ProductPage({Key? key, this.category = Category.all}) : super(key: key);
final Category category;
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_gallery/demo/shrine/colors.dart';
class LoginPage extends StatefulWidget {
const LoginPage({Key? key}) : super(key: key);
@override
_LoginPageState createState() => _LoginPageState();
}
......
......@@ -14,6 +14,8 @@ import 'package:flutter_gallery/demo/shrine/model/product.dart';
const double _leftColumnWidth = 60.0;
class ShoppingCartPage extends StatefulWidget {
const ShoppingCartPage({Key? key}) : super(key: key);
@override
_ShoppingCartPageState createState() => _ShoppingCartPageState();
}
......@@ -103,7 +105,7 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
}
class ShoppingCartSummary extends StatelessWidget {
const ShoppingCartSummary({this.model});
const ShoppingCartSummary({Key? key, this.model}) : super(key: key);
final AppStateModel? model;
......@@ -183,10 +185,11 @@ class ShoppingCartSummary extends StatelessWidget {
class ShoppingCartRow extends StatelessWidget {
const ShoppingCartRow({
Key? key,
required this.product,
required this.quantity,
this.onPressed,
});
}) : super(key: key);
final Product product;
final int? quantity;
......
......@@ -10,8 +10,8 @@ import 'package:flutter_gallery/demo/shrine/model/app_state_model.dart';
import 'package:flutter_gallery/demo/shrine/model/product.dart';
class ProductCard extends StatelessWidget {
const ProductCard({ this.imageAspectRatio = 33 / 49, this.product })
: assert(imageAspectRatio > 0);
const ProductCard({ Key? key, this.imageAspectRatio = 33 / 49, this.product })
: assert(imageAspectRatio > 0), super(key: key);
final double imageAspectRatio;
final Product? product;
......
......@@ -9,9 +9,10 @@ import 'package:flutter_gallery/demo/shrine/supplemental/product_card.dart';
class TwoProductCardColumn extends StatelessWidget {
const TwoProductCardColumn({
Key? key,
required this.bottom,
this.top,
});
}) : super(key: key);
final Product? bottom, top;
......@@ -57,7 +58,7 @@ class TwoProductCardColumn extends StatelessWidget {
}
class OneProductCardColumn extends StatelessWidget {
const OneProductCardColumn({this.product});
const OneProductCardColumn({Key? key, this.product}) : super(key: key);
final Product? product;
......
......@@ -11,5 +11,5 @@ class ShrineDemo extends StatelessWidget {
static const String routeName = '/shrine'; // Used by the Gallery app.
@override
Widget build(BuildContext context) => ShrineApp();
Widget build(BuildContext context) => const ShrineApp();
}
......@@ -8,10 +8,11 @@ import 'package:flutter/material.dart';
@immutable
class ColorPicker extends StatelessWidget {
const ColorPicker({
Key? key,
required this.colors,
required this.selectedColor,
this.onColorSelection,
});
}) : super(key: key);
final Set<Color> colors;
final Color selectedColor;
......
......@@ -39,6 +39,8 @@ class TextStyleItem extends StatelessWidget {
}
class TypographyDemo extends StatelessWidget {
const TypographyDemo({Key? key}) : super(key: key);
static const String routeName = '/typography';
@override
......
......@@ -92,7 +92,7 @@ class VideoCard extends StatelessWidget {
}
class VideoPlayerLoading extends StatefulWidget {
const VideoPlayerLoading(this.controller);
const VideoPlayerLoading(this.controller, {Key? key}) : super(key: key);
final VideoPlayerController? controller;
......@@ -136,7 +136,7 @@ class _VideoPlayerLoadingState extends State<VideoPlayerLoading> {
}
class VideoPlayPause extends StatefulWidget {
const VideoPlayPause(this.controller);
const VideoPlayPause(this.controller, {Key? key}) : super(key: key);
final VideoPlayerController? controller;
......@@ -202,9 +202,10 @@ class _VideoPlayPauseState extends State<VideoPlayPause> {
class FadeAnimation extends StatefulWidget {
const FadeAnimation({
Key? key,
this.child,
this.duration = const Duration(milliseconds: 500),
});
}) : super(key: key);
final Widget? child;
final Duration duration;
......@@ -264,9 +265,10 @@ class _FadeAnimationState extends State<FadeAnimation> with SingleTickerProvider
class ConnectivityOverlay extends StatefulWidget {
const ConnectivityOverlay({
Key? key,
this.child,
this.connectedCompleter,
});
}) : super(key: key);
final Widget? child;
final Completer<void>? connectedCompleter;
......
......@@ -179,13 +179,14 @@ class _BackAppBar extends StatelessWidget {
class Backdrop extends StatefulWidget {
const Backdrop({
Key? key,
this.frontAction,
this.frontTitle,
this.frontHeading,
this.frontLayer,
this.backTitle,
this.backLayer,
});
}) : super(key: key);
final Widget? frontAction;
final Widget? frontTitle;
......
......@@ -42,12 +42,13 @@ class ComponentDemoTabData {
class TabbedComponentDemoScaffold extends StatelessWidget {
const TabbedComponentDemoScaffold({
Key? key,
this.title,
this.demos,
this.actions,
this.isScrollable = true,
this.showExampleCodeAction = true,
});
}) : super(key: key);
final List<ComponentDemoTabData>? demos;
final String? title;
......@@ -147,7 +148,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
}
class FullScreenCodeDialog extends StatefulWidget {
const FullScreenCodeDialog({ this.exampleCodeTag });
const FullScreenCodeDialog({ Key? key, this.exampleCodeTag }) : super(key: key);
final String? exampleCodeTag;
......
......@@ -104,7 +104,7 @@ List<GalleryDemo> _buildGalleryDemos() {
icon: GalleryIcons.custom_typography,
category: _kDemos,
routeName: FortnightlyDemo.routeName,
buildRoute: (BuildContext context) => FortnightlyDemo(),
buildRoute: (BuildContext context) => const FortnightlyDemo(),
),
GalleryDemo(
title: 'Contact profile',
......@@ -112,7 +112,7 @@ List<GalleryDemo> _buildGalleryDemos() {
icon: GalleryIcons.account_box,
category: _kDemos,
routeName: ContactsDemo.routeName,
buildRoute: (BuildContext context) => ContactsDemo(),
buildRoute: (BuildContext context) => const ContactsDemo(),
),
GalleryDemo(
title: 'Animation',
......@@ -146,7 +146,7 @@ List<GalleryDemo> _buildGalleryDemos() {
icon: GalleryIcons.colors,
category: _kStyle,
routeName: ColorsDemo.routeName,
buildRoute: (BuildContext context) => ColorsDemo(),
buildRoute: (BuildContext context) => const ColorsDemo(),
),
GalleryDemo(
title: 'Typography',
......@@ -154,7 +154,7 @@ List<GalleryDemo> _buildGalleryDemos() {
icon: GalleryIcons.custom_typography,
category: _kStyle,
routeName: TypographyDemo.routeName,
buildRoute: (BuildContext context) => TypographyDemo(),
buildRoute: (BuildContext context) => const TypographyDemo(),
),
// Material Components
......@@ -164,7 +164,7 @@ List<GalleryDemo> _buildGalleryDemos() {
icon: GalleryIcons.backdrop,
category: _kMaterialComponents,
routeName: BackdropDemo.routeName,
buildRoute: (BuildContext context) => BackdropDemo(),
buildRoute: (BuildContext context) => const BackdropDemo(),
),
GalleryDemo(
title: 'Banner',
......@@ -182,7 +182,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: BottomAppBarDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/BottomAppBar-class.html',
buildRoute: (BuildContext context) => BottomAppBarDemo(),
buildRoute: (BuildContext context) => const BottomAppBarDemo(),
),
GalleryDemo(
title: 'Bottom navigation',
......@@ -191,7 +191,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: BottomNavigationDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/BottomNavigationBar-class.html',
buildRoute: (BuildContext context) => BottomNavigationDemo(),
buildRoute: (BuildContext context) => const BottomNavigationDemo(),
),
GalleryDemo(
title: 'Bottom sheet: Modal',
......@@ -200,7 +200,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: ModalBottomSheetDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/showModalBottomSheet.html',
buildRoute: (BuildContext context) => ModalBottomSheetDemo(),
buildRoute: (BuildContext context) => const ModalBottomSheetDemo(),
),
GalleryDemo(
title: 'Bottom sheet: Persistent',
......@@ -209,7 +209,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: PersistentBottomSheetDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/ScaffoldState/showBottomSheet.html',
buildRoute: (BuildContext context) => PersistentBottomSheetDemo(),
buildRoute: (BuildContext context) => const PersistentBottomSheetDemo(),
),
GalleryDemo(
title: 'Buttons',
......@@ -217,7 +217,7 @@ List<GalleryDemo> _buildGalleryDemos() {
icon: GalleryIcons.generic_buttons,
category: _kMaterialComponents,
routeName: ButtonsDemo.routeName,
buildRoute: (BuildContext context) => ButtonsDemo(),
buildRoute: (BuildContext context) => const ButtonsDemo(),
),
GalleryDemo(
title: 'Buttons: Floating Action Button',
......@@ -226,7 +226,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: TabsFabDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/FloatingActionButton-class.html',
buildRoute: (BuildContext context) => TabsFabDemo(),
buildRoute: (BuildContext context) => const TabsFabDemo(),
),
GalleryDemo(
title: 'Cards',
......@@ -235,7 +235,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: CardsDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/Card-class.html',
buildRoute: (BuildContext context) => CardsDemo(),
buildRoute: (BuildContext context) => const CardsDemo(),
),
GalleryDemo(
title: 'Chips',
......@@ -244,7 +244,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: ChipDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/Chip-class.html',
buildRoute: (BuildContext context) => ChipDemo(),
buildRoute: (BuildContext context) => const ChipDemo(),
),
GalleryDemo(
title: 'Data tables',
......@@ -253,7 +253,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: DataTableDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/PaginatedDataTable-class.html',
buildRoute: (BuildContext context) => DataTableDemo(),
buildRoute: (BuildContext context) => const DataTableDemo(),
),
GalleryDemo(
title: 'Dialogs',
......@@ -262,7 +262,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: DialogDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/showDialog.html',
buildRoute: (BuildContext context) => DialogDemo(),
buildRoute: (BuildContext context) => const DialogDemo(),
),
GalleryDemo(
title: 'Elevations',
......@@ -272,7 +272,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: ElevationDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/Material/elevation.html',
buildRoute: (BuildContext context) => ElevationDemo(),
buildRoute: (BuildContext context) => const ElevationDemo(),
),
GalleryDemo(
title: 'Expand/collapse list control',
......@@ -281,7 +281,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: ExpansionTileListDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/ExpansionTile-class.html',
buildRoute: (BuildContext context) => ExpansionTileListDemo(),
buildRoute: (BuildContext context) => const ExpansionTileListDemo(),
),
GalleryDemo(
title: 'Expansion panels',
......@@ -290,7 +290,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: ExpansionPanelsDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/ExpansionPanel-class.html',
buildRoute: (BuildContext context) => ExpansionPanelsDemo(),
buildRoute: (BuildContext context) => const ExpansionPanelsDemo(),
),
GalleryDemo(
title: 'Grid',
......@@ -308,7 +308,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: IconsDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/IconButton-class.html',
buildRoute: (BuildContext context) => IconsDemo(),
buildRoute: (BuildContext context) => const IconsDemo(),
),
GalleryDemo(
title: 'Lists',
......@@ -353,7 +353,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: DrawerDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/Drawer-class.html',
buildRoute: (BuildContext context) => DrawerDemo(),
buildRoute: (BuildContext context) => const DrawerDemo(),
),
GalleryDemo(
title: 'Pagination',
......@@ -362,7 +362,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: PageSelectorDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/TabBarView-class.html',
buildRoute: (BuildContext context) => PageSelectorDemo(),
buildRoute: (BuildContext context) => const PageSelectorDemo(),
),
GalleryDemo(
title: 'Pickers',
......@@ -371,7 +371,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: DateAndTimePickerDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/showDatePicker.html',
buildRoute: (BuildContext context) => DateAndTimePickerDemo(),
buildRoute: (BuildContext context) => const DateAndTimePickerDemo(),
),
GalleryDemo(
title: 'Progress indicators',
......@@ -380,7 +380,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: ProgressIndicatorDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/LinearProgressIndicator-class.html',
buildRoute: (BuildContext context) => ProgressIndicatorDemo(),
buildRoute: (BuildContext context) => const ProgressIndicatorDemo(),
),
GalleryDemo(
title: 'Pull to refresh',
......@@ -398,7 +398,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: SearchDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/showSearch.html',
buildRoute: (BuildContext context) => SearchDemo(),
buildRoute: (BuildContext context) => const SearchDemo(),
),
GalleryDemo(
title: 'Selection controls',
......@@ -406,7 +406,7 @@ List<GalleryDemo> _buildGalleryDemos() {
icon: GalleryIcons.check_box,
category: _kMaterialComponents,
routeName: SelectionControlsDemo.routeName,
buildRoute: (BuildContext context) => SelectionControlsDemo(),
buildRoute: (BuildContext context) => const SelectionControlsDemo(),
),
GalleryDemo(
title: 'Sliders',
......@@ -415,7 +415,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: SliderDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/Slider-class.html',
buildRoute: (BuildContext context) => SliderDemo(),
buildRoute: (BuildContext context) => const SliderDemo(),
),
GalleryDemo(
title: 'Snackbar',
......@@ -433,7 +433,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: TabsDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/TabBarView-class.html',
buildRoute: (BuildContext context) => TabsDemo(),
buildRoute: (BuildContext context) => const TabsDemo(),
),
GalleryDemo(
title: 'Tabs: Scrolling',
......@@ -442,7 +442,7 @@ List<GalleryDemo> _buildGalleryDemos() {
icon: GalleryIcons.tabs,
routeName: ScrollableTabsDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/TabBar-class.html',
buildRoute: (BuildContext context) => ScrollableTabsDemo(),
buildRoute: (BuildContext context) => const ScrollableTabsDemo(),
),
GalleryDemo(
title: 'Text fields',
......@@ -460,7 +460,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kMaterialComponents,
routeName: TooltipDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/material/Tooltip-class.html',
buildRoute: (BuildContext context) => TooltipDemo(),
buildRoute: (BuildContext context) => const TooltipDemo(),
),
// Cupertino Components
......@@ -470,7 +470,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kCupertinoComponents,
routeName: CupertinoProgressIndicatorDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/cupertino/CupertinoActivityIndicator-class.html',
buildRoute: (BuildContext context) => CupertinoProgressIndicatorDemo(),
buildRoute: (BuildContext context) => const CupertinoProgressIndicatorDemo(),
),
GalleryDemo(
title: 'Alerts',
......@@ -478,7 +478,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kCupertinoComponents,
routeName: CupertinoAlertDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/cupertino/showCupertinoDialog.html',
buildRoute: (BuildContext context) => CupertinoAlertDemo(),
buildRoute: (BuildContext context) => const CupertinoAlertDemo(),
),
GalleryDemo(
title: 'Buttons',
......@@ -486,7 +486,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kCupertinoComponents,
routeName: CupertinoButtonsDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/cupertino/CupertinoButton-class.html',
buildRoute: (BuildContext context) => CupertinoButtonsDemo(),
buildRoute: (BuildContext context) => const CupertinoButtonsDemo(),
),
GalleryDemo(
title: 'Navigation',
......@@ -502,7 +502,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kCupertinoComponents,
routeName: CupertinoPickerDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/cupertino/CupertinoPicker-class.html',
buildRoute: (BuildContext context) => CupertinoPickerDemo(),
buildRoute: (BuildContext context) => const CupertinoPickerDemo(),
),
GalleryDemo(
title: 'Pull to refresh',
......@@ -510,7 +510,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kCupertinoComponents,
routeName: CupertinoRefreshControlDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/cupertino/CupertinoSliverRefreshControl-class.html',
buildRoute: (BuildContext context) => CupertinoRefreshControlDemo(),
buildRoute: (BuildContext context) => const CupertinoRefreshControlDemo(),
),
GalleryDemo(
title: 'Segmented Control',
......@@ -518,7 +518,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kCupertinoComponents,
routeName: CupertinoSegmentedControlDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/cupertino/CupertinoSegmentedControl-class.html',
buildRoute: (BuildContext context) => CupertinoSegmentedControlDemo(),
buildRoute: (BuildContext context) => const CupertinoSegmentedControlDemo(),
),
GalleryDemo(
title: 'Sliders',
......@@ -526,7 +526,7 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kCupertinoComponents,
routeName: CupertinoSliderDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/cupertino/CupertinoSlider-class.html',
buildRoute: (BuildContext context) => CupertinoSliderDemo(),
buildRoute: (BuildContext context) => const CupertinoSliderDemo(),
),
GalleryDemo(
title: 'Switches',
......@@ -534,14 +534,14 @@ List<GalleryDemo> _buildGalleryDemos() {
category: _kCupertinoComponents,
routeName: CupertinoSwitchDemo.routeName,
documentationUrl: 'https://api.flutter.dev/flutter/cupertino/CupertinoSwitch-class.html',
buildRoute: (BuildContext context) => CupertinoSwitchDemo(),
buildRoute: (BuildContext context) => const CupertinoSwitchDemo(),
),
GalleryDemo(
title: 'Text Fields',
icon: GalleryIcons.text_fields_alt,
category: _kCupertinoComponents,
routeName: CupertinoTextFieldDemo.routeName,
buildRoute: (BuildContext context) => CupertinoTextFieldDemo(),
buildRoute: (BuildContext context) => const CupertinoTextFieldDemo(),
),
// Media
......@@ -551,7 +551,7 @@ List<GalleryDemo> _buildGalleryDemos() {
icon: GalleryIcons.animation,
category: _kMedia,
routeName: ImagesDemo.routeName,
buildRoute: (BuildContext context) => ImagesDemo(),
buildRoute: (BuildContext context) => const ImagesDemo(),
),
GalleryDemo(
title: 'Video',
......
......@@ -12,84 +12,84 @@ void main() {
group('All material demos meet recommended tap target sizes', () {
testWidgets('backdrop_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: BackdropDemo()));
await tester.pumpWidget(const MaterialApp(home: BackdropDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('bottom_app_bar_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: BottomAppBarDemo()));
await tester.pumpWidget(const MaterialApp(home: BottomAppBarDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('bottom_navigation_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: BottomNavigationDemo()));
await tester.pumpWidget(const MaterialApp(home: BottomNavigationDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('buttons_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ButtonsDemo()));
await tester.pumpWidget(const MaterialApp(home: ButtonsDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('cards_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: CardsDemo()));
await tester.pumpWidget(const MaterialApp(home: CardsDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('chip_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ChipDemo()));
await tester.pumpWidget(const MaterialApp(home: ChipDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
}, skip: true); // https://github.com/flutter/flutter/issues/42455
testWidgets('data_table_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: DataTableDemo()));
await tester.pumpWidget(const MaterialApp(home: DataTableDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('date_and_time_picker_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: DateAndTimePickerDemo()));
await tester.pumpWidget(const MaterialApp(home: DateAndTimePickerDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('dialog_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: DialogDemo()));
await tester.pumpWidget(const MaterialApp(home: DialogDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('drawer_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: DrawerDemo()));
await tester.pumpWidget(const MaterialApp(home: DrawerDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('elevation_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ElevationDemo()));
await tester.pumpWidget(const MaterialApp(home: ElevationDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('expansion_panels_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ExpansionPanelsDemo()));
await tester.pumpWidget(const MaterialApp(home: ExpansionPanelsDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
......@@ -103,7 +103,7 @@ void main() {
testWidgets('icons_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: IconsDemo()));
await tester.pumpWidget(const MaterialApp(home: IconsDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
......@@ -131,7 +131,7 @@ void main() {
testWidgets('modal_bottom_sheet_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ModalBottomSheetDemo()));
await tester.pumpWidget(const MaterialApp(home: ModalBottomSheetDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
......@@ -145,21 +145,21 @@ void main() {
testWidgets('page_selector_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: PageSelectorDemo()));
await tester.pumpWidget(const MaterialApp(home: PageSelectorDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('persistent_bottom_sheet_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: PersistentBottomSheetDemo()));
await tester.pumpWidget(const MaterialApp(home: PersistentBottomSheetDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('progress_indicator_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ProgressIndicatorDemo()));
await tester.pumpWidget(const MaterialApp(home: ProgressIndicatorDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
......@@ -173,28 +173,28 @@ void main() {
testWidgets('scrollable_tabs_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ScrollableTabsDemo()));
await tester.pumpWidget(const MaterialApp(home: ScrollableTabsDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('search_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: SearchDemo()));
await tester.pumpWidget(const MaterialApp(home: SearchDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('selection_controls_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: SelectionControlsDemo()));
await tester.pumpWidget(const MaterialApp(home: SelectionControlsDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('slider_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: SliderDemo()));
await tester.pumpWidget(const MaterialApp(home: SliderDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
......@@ -208,14 +208,14 @@ void main() {
testWidgets('tabs_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: TabsDemo()));
await tester.pumpWidget(const MaterialApp(home: TabsDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('tabs_fab_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: TabsFabDemo()));
await tester.pumpWidget(const MaterialApp(home: TabsFabDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
......@@ -229,14 +229,14 @@ void main() {
testWidgets('tooltip_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: TooltipDemo()));
await tester.pumpWidget(const MaterialApp(home: TooltipDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
testWidgets('expansion_tile_list_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ExpansionTileListDemo()));
await tester.pumpWidget(const MaterialApp(home: ExpansionTileListDemo()));
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
handle.dispose();
});
......@@ -245,84 +245,84 @@ void main() {
group('All material demos have labeled tap targets', () {
testWidgets('backdrop_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: BackdropDemo()));
await tester.pumpWidget(const MaterialApp(home: BackdropDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('bottom_app_bar_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: BottomAppBarDemo()));
await tester.pumpWidget(const MaterialApp(home: BottomAppBarDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('bottom_navigation_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: BottomNavigationDemo()));
await tester.pumpWidget(const MaterialApp(home: BottomNavigationDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('buttons_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ButtonsDemo()));
await tester.pumpWidget(const MaterialApp(home: ButtonsDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('cards_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: CardsDemo()));
await tester.pumpWidget(const MaterialApp(home: CardsDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('chip_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ChipDemo()));
await tester.pumpWidget(const MaterialApp(home: ChipDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('data_table_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: DataTableDemo()));
await tester.pumpWidget(const MaterialApp(home: DataTableDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
}, skip: true); // DataTables are not accessible, https://github.com/flutter/flutter/issues/10830
testWidgets('date_and_time_picker_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: DateAndTimePickerDemo()));
await tester.pumpWidget(const MaterialApp(home: DateAndTimePickerDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('dialog_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: DialogDemo()));
await tester.pumpWidget(const MaterialApp(home: DialogDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('drawer_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: DrawerDemo()));
await tester.pumpWidget(const MaterialApp(home: DrawerDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('elevation_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ElevationDemo()));
await tester.pumpWidget(const MaterialApp(home: ElevationDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('expansion_panels_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ExpansionPanelsDemo()));
await tester.pumpWidget(const MaterialApp(home: ExpansionPanelsDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
......@@ -336,7 +336,7 @@ void main() {
testWidgets('icons_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: IconsDemo()));
await tester.pumpWidget(const MaterialApp(home: IconsDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
......@@ -364,7 +364,7 @@ void main() {
testWidgets('modal_bottom_sheet_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ModalBottomSheetDemo()));
await tester.pumpWidget(const MaterialApp(home: ModalBottomSheetDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
......@@ -378,21 +378,21 @@ void main() {
testWidgets('page_selector_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: PageSelectorDemo()));
await tester.pumpWidget(const MaterialApp(home: PageSelectorDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('persistent_bottom_sheet_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: PersistentBottomSheetDemo()));
await tester.pumpWidget(const MaterialApp(home: PersistentBottomSheetDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('progress_indicator_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ProgressIndicatorDemo()));
await tester.pumpWidget(const MaterialApp(home: ProgressIndicatorDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
......@@ -406,28 +406,28 @@ void main() {
testWidgets('scrollable_tabs_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ScrollableTabsDemo()));
await tester.pumpWidget(const MaterialApp(home: ScrollableTabsDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('search_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: SearchDemo()));
await tester.pumpWidget(const MaterialApp(home: SearchDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('selection_controls_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: SelectionControlsDemo()));
await tester.pumpWidget(const MaterialApp(home: SelectionControlsDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('slider_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: SliderDemo()));
await tester.pumpWidget(const MaterialApp(home: SliderDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
......@@ -441,14 +441,14 @@ void main() {
testWidgets('tabs_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: TabsDemo()));
await tester.pumpWidget(const MaterialApp(home: TabsDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('tabs_fab_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: TabsFabDemo()));
await tester.pumpWidget(const MaterialApp(home: TabsFabDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
......@@ -462,14 +462,14 @@ void main() {
testWidgets('tooltip_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: TooltipDemo()));
await tester.pumpWidget(const MaterialApp(home: TooltipDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
testWidgets('expansion_tile_list_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: ExpansionTileListDemo()));
await tester.pumpWidget(const MaterialApp(home: ExpansionTileListDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
......@@ -493,7 +493,7 @@ void main() {
testWidgets('backdrop_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: BackdropDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const BackdropDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -501,7 +501,7 @@ void main() {
testWidgets('bottom_app_bar_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: BottomAppBarDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const BottomAppBarDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -509,7 +509,7 @@ void main() {
testWidgets('bottom_navigation_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: BottomNavigationDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const BottomNavigationDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -517,7 +517,7 @@ void main() {
testWidgets('buttons_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: ButtonsDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const ButtonsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -525,7 +525,7 @@ void main() {
testWidgets('cards_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: CardsDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const CardsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -533,7 +533,7 @@ void main() {
testWidgets('chip_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: ChipDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const ChipDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -541,7 +541,7 @@ void main() {
testWidgets('data_table_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: DataTableDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const DataTableDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -549,7 +549,7 @@ void main() {
testWidgets('date_and_time_picker_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: DateAndTimePickerDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const DateAndTimePickerDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -557,7 +557,7 @@ void main() {
testWidgets('dialog_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: DialogDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const DialogDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
}, skip: theme == ThemeData.dark()); // Raised Button does not follow
......@@ -567,7 +567,7 @@ void main() {
testWidgets('drawer_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: DrawerDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const DrawerDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -575,7 +575,7 @@ void main() {
testWidgets('elevation_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: ElevationDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const ElevationDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -583,7 +583,7 @@ void main() {
testWidgets('expansion_panels_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: ExpansionPanelsDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const ExpansionPanelsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -599,7 +599,7 @@ void main() {
testWidgets('icons_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: IconsDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const IconsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -632,7 +632,7 @@ void main() {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
MaterialApp(theme: theme, home: ModalBottomSheetDemo())
MaterialApp(theme: theme, home: const ModalBottomSheetDemo())
);
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
......@@ -651,7 +651,7 @@ void main() {
testWidgets('page_selector_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: PageSelectorDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const PageSelectorDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -660,7 +660,7 @@ void main() {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
MaterialApp(theme: theme, home: PersistentBottomSheetDemo())
MaterialApp(theme: theme, home: const PersistentBottomSheetDemo())
);
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
......@@ -671,7 +671,7 @@ void main() {
testWidgets('progress_indicator_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: ProgressIndicatorDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const ProgressIndicatorDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -687,7 +687,7 @@ void main() {
testWidgets('scrollable_tabs_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: ScrollableTabsDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const ScrollableTabsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -695,7 +695,7 @@ void main() {
testWidgets('search_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: SearchDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const SearchDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -703,7 +703,7 @@ void main() {
testWidgets('selection_controls_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: SelectionControlsDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const SelectionControlsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -711,7 +711,7 @@ void main() {
testWidgets('slider_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: SliderDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const SliderDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -731,7 +731,7 @@ void main() {
testWidgets('tabs_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: TabsDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const TabsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -739,7 +739,7 @@ void main() {
testWidgets('tabs_fab_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: TabsFabDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const TabsFabDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -755,7 +755,7 @@ void main() {
testWidgets('tooltip_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: TooltipDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const TooltipDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -763,7 +763,7 @@ void main() {
testWidgets('expansion_tile_list_demo $themeName', (WidgetTester tester) async {
tester.binding.addTime(const Duration(seconds: 3));
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(theme: theme, home: ExpansionTileListDemo()));
await tester.pumpWidget(MaterialApp(theme: theme, home: const ExpansionTileListDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......
......@@ -11,7 +11,7 @@ void main() {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS),
home: ChipDemo(),
home: const ChipDemo(),
));
expect(tester.getSemantics(find.byIcon(Icons.vignette)), matchesSemantics(
......
......@@ -10,7 +10,7 @@ void main() {
testWidgets('Drawer header does not scroll', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS),
home: DrawerDemo(),
home: const DrawerDemo(),
));
await tester.tap(find.text('Tap here to open the drawer'));
......
......@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
Future<void> main() async {
testWidgets('Expansion panel demo: radio tile selection changes on tap', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: ExpansionPanelsDemo()));
await tester.pumpWidget(const MaterialApp(home: ExpansionPanelsDemo()));
expect(_expandIcons, findsNWidgets(3));
......
......@@ -17,10 +17,12 @@ final List<PageWidget> _allPages = <PageWidget>[
void main() {
enableFlutterDriverExtension(handler: driverDataHandler.handleMessage);
runApp(MaterialApp(home: Home()));
runApp(const MaterialApp(home: Home()));
}
class Home extends StatelessWidget {
const Home({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
......
......@@ -17,16 +17,18 @@ import 'page.dart';
const String kEventsFileName = 'touchEvents';
class MotionEventsPage extends PageWidget {
const MotionEventsPage()
: super('Motion Event Tests', const ValueKey<String>('MotionEventsListTile'));
const MotionEventsPage({Key key})
: super('Motion Event Tests', const ValueKey<String>('MotionEventsListTile'), key: key);
@override
Widget build(BuildContext context) {
return MotionEventsBody();
return const MotionEventsBody();
}
}
class MotionEventsBody extends StatefulWidget {
const MotionEventsBody({Key key}) : super(key: key);
@override
State createState() => MotionEventsBodyState();
}
......@@ -223,7 +225,7 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
}
class TouchEventDiff extends StatelessWidget {
const TouchEventDiff(this.originalEvent, this.synthesizedEvent);
const TouchEventDiff(this.originalEvent, this.synthesizedEvent, {Key key}) : super(key: key);
final Map<String, dynamic> originalEvent;
final Map<String, dynamic> synthesizedEvent;
......
......@@ -12,14 +12,16 @@ import 'future_data_handler.dart';
import 'page.dart';
class NestedViewEventPage extends PageWidget {
const NestedViewEventPage()
: super('Nested View Event Tests', const ValueKey<String>('NestedViewEventTile'));
const NestedViewEventPage({Key key})
: super('Nested View Event Tests', const ValueKey<String>('NestedViewEventTile'), key: key);
@override
Widget build(BuildContext context) => NestedViewEventBody();
Widget build(BuildContext context) => const NestedViewEventBody();
}
class NestedViewEventBody extends StatefulWidget {
const NestedViewEventBody({Key key}) : super(key: key);
@override
State<NestedViewEventBody> createState() => NestedViewEventBodyState();
}
......
......@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
//
/// A testing page has to override this in order to be put as one of the items in the main page.
abstract class PageWidget extends StatelessWidget {
const PageWidget(this.title, this.tileKey);
const PageWidget(this.title, this.tileKey, {Key key}) : super(key: key);
/// The title of the testing page
///
......
......@@ -28,7 +28,7 @@ void main() {
///
/// Rewiring semantics is a signal to native IOS test that the test has passed.
class LifeCycleSpy extends StatefulWidget {
const LifeCycleSpy();
const LifeCycleSpy({Key key}) : super(key: key);
@override
_LifeCycleSpyState createState() => _LifeCycleSpyState();
......
......@@ -4,9 +4,11 @@
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
......
......@@ -7,11 +7,13 @@ import 'package:flutter_driver/driver_extension.dart';
void main() {
enableFlutterDriverExtension();
runApp(MyApp());
runApp(const MyApp());
}
/// The main app entrance of the test
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
......@@ -50,7 +52,7 @@ class _MyHomePageState extends State<MyHomePage> {
Navigator.push(
context,
MaterialPageRoute<PlatformViewPage>(
builder: (BuildContext context) => PlatformViewPage()),
builder: (BuildContext context) => const PlatformViewPage()),
);
},
),
......@@ -67,7 +69,9 @@ class _MyHomePageState extends State<MyHomePage> {
/// A page contains the platform view to be tested.
class PlatformViewPage extends StatelessWidget {
final Key button = const ValueKey<String>('plus_button');
const PlatformViewPage({Key key}) : super(key: key);
static Key button = const ValueKey<String>('plus_button');
@override
Widget build(BuildContext context) {
......
......@@ -7,10 +7,12 @@ import 'package:flutter/material.dart';
String? unused;
void main() {
runApp(MyApp());
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
......
......@@ -12,10 +12,12 @@ import 'src/test_step.dart';
void main() {
enableFlutterDriverExtension();
runApp(TestApp());
runApp(const TestApp());
}
class TestApp extends StatefulWidget {
const TestApp({Key key}) : super(key: key);
@override
_TestAppState createState() => _TestAppState();
}
......
......@@ -7,10 +7,12 @@ import 'package:flutter_driver/driver_extension.dart';
void main() {
enableFlutterDriverExtension();
runApp(DriverTestApp());
runApp(const DriverTestApp());
}
class DriverTestApp extends StatefulWidget {
const DriverTestApp({Key key}) : super(key: key);
@override
State<StatefulWidget> createState() {
return DriverTestAppState();
......
......@@ -8,10 +8,12 @@ import 'package:flutter_driver/driver_extension.dart';
/// This application does nothing but show a empty screen.
void main() {
enableFlutterDriverExtension();
runApp(Empty());
runApp(const Empty());
}
class Empty extends StatelessWidget {
const Empty({Key key}) : super(key: key);
@override
Widget build(BuildContext context) => Container();
}
......@@ -12,21 +12,25 @@ void main() {
// TODO(cbernaschina): remove when test flakiness is resolved
return 'keyboard_resize';
});
runApp(MyApp());
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Text Editing',
theme: ThemeData(primarySwatch: Colors.blue),
home: MyHomePage(),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
......
......@@ -10,21 +10,25 @@ import 'keys.dart' as keys;
void main() {
enableFlutterDriverExtension();
runApp(MyApp());
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Keyboard & TextField',
theme: ThemeData(primarySwatch: Colors.blue),
home: MyHomePage(),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
......
......@@ -10,10 +10,12 @@ import 'package:flutter_driver/driver_extension.dart';
/// license in it.
void main() {
enableFlutterDriverExtension();
runApp(ShowLicenses());
runApp(const ShowLicenses());
}
class ShowLicenses extends StatelessWidget {
const ShowLicenses({Key key}) : super(key: key);
Widget _buildTestResultWidget(
BuildContext context,
AsyncSnapshot<List<LicenseEntry>> snapshot,
......
......@@ -12,10 +12,12 @@ import 'package:flutter_driver/driver_extension.dart';
void main() {
enableFlutterDriverExtension();
runApp(Toggler());
runApp(const Toggler());
}
class Toggler extends StatefulWidget {
const Toggler({Key key}) : super(key: key);
@override
State<Toggler> createState() => TogglerState();
}
......
......@@ -4,9 +4,11 @@
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
......
......@@ -294,7 +294,7 @@ class UndoableDirectionalFocusAction extends UndoableFocusActionBase<Directional
/// A button class that takes focus when clicked.
class DemoButton extends StatefulWidget {
const DemoButton({this.name});
const DemoButton({Key key, this.name}) : super(key: key);
final String name;
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class AnimatedIconsTestApp extends StatelessWidget {
const AnimatedIconsTestApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
......@@ -17,7 +19,7 @@ class AnimatedIconsTestApp extends StatelessWidget {
}
class IconsList extends StatelessWidget {
const IconsList();
const IconsList({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
......@@ -28,7 +30,7 @@ class IconsList extends StatelessWidget {
}
class IconSampleRow extends StatefulWidget {
const IconSampleRow(this.sample);
const IconSampleRow(this.sample, {Key key}) : super(key: key);
final IconSample sample;
......@@ -105,4 +107,4 @@ class IconSample {
final String description;
}
void main() => runApp(AnimatedIconsTestApp());
void main() => runApp(const AnimatedIconsTestApp());
......@@ -18,6 +18,8 @@ class CardModel {
}
class CardCollection extends StatefulWidget {
const CardCollection({Key key}) : super(key: key);
@override
CardCollectionState createState() => CardCollectionState();
}
......@@ -389,7 +391,7 @@ class CardCollectionState extends State<CardCollection> {
}
void main() {
runApp(MaterialApp(
runApp(const MaterialApp(
title: 'Cards',
home: CardCollection(),
));
......
......@@ -10,10 +10,12 @@ class ColorTestingDemo extends StatelessWidget {
static const String routeName = '/color_demo';
@override
Widget build(BuildContext context) => ColorDemoHome();
Widget build(BuildContext context) => const ColorDemoHome();
}
class ColorDemoHome extends StatelessWidget {
const ColorDemoHome({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
......@@ -85,7 +87,7 @@ class ColorRow extends StatelessWidget {
}
void main() {
runApp(MaterialApp(
runApp(const MaterialApp(
title: 'Color Testing Demo',
home: ColorDemoHome(),
));
......
......@@ -19,9 +19,11 @@ final Map<int, Color> m2SwatchColors = <int, Color>{
};
final MaterialColor m2Swatch = MaterialColor(m2SwatchColors[500].value, m2SwatchColors);
void main() => runApp(MyApp());
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
static const String _title = 'Density Test';
@override
......@@ -132,7 +134,7 @@ class LabeledCheckbox extends StatelessWidget {
}
class Options extends StatefulWidget {
const Options(this.model);
const Options(this.model, {Key key}) : super(key: key);
final OptionModel model;
......
......@@ -7,6 +7,8 @@ import 'dart:math' as math;
import 'package:flutter/material.dart';
class ExampleDragTarget extends StatefulWidget {
const ExampleDragTarget({Key key}) : super(key: key);
@override
ExampleDragTargetState createState() => ExampleDragTargetState();
}
......@@ -174,7 +176,7 @@ class DashOutlineCirclePainter extends CustomPainter {
}
class MovableBall extends StatelessWidget {
const MovableBall(this.position, this.ballPosition, this.callback);
const MovableBall(this.position, this.ballPosition, this.callback, {Key key}) : super(key: key);
final int position;
final int ballPosition;
......@@ -223,6 +225,8 @@ class MovableBall extends StatelessWidget {
}
class DragAndDropApp extends StatefulWidget {
const DragAndDropApp({Key key}) : super(key: key);
@override
DragAndDropAppState createState() => DragAndDropAppState();
}
......@@ -270,7 +274,7 @@ class DragAndDropAppState extends State<DragAndDropApp> {
),
Expanded(
child: Row(
children: <Widget>[
children: const <Widget>[
Expanded(child: ExampleDragTarget()),
Expanded(child: ExampleDragTarget()),
Expanded(child: ExampleDragTarget()),
......@@ -295,7 +299,7 @@ class DragAndDropAppState extends State<DragAndDropApp> {
}
void main() {
runApp(MaterialApp(
runApp(const MaterialApp(
title: 'Drag and Drop Flutter Demo',
home: DragAndDropApp(),
));
......
......@@ -13,7 +13,7 @@ void main() {
}
class DemoButton extends StatefulWidget {
const DemoButton({this.name, this.canRequestFocus = true, this.autofocus = false});
const DemoButton({Key key, this.name, this.canRequestFocus = true, this.autofocus = false}) : super(key: key);
final String name;
final bool canRequestFocus;
......
......@@ -12,7 +12,7 @@ void main() {
}
class DemoButton extends StatelessWidget {
const DemoButton({this.name});
const DemoButton({Key key, this.name}) : super(key: key);
final String name;
......
......@@ -86,6 +86,8 @@ class Marker extends StatelessWidget {
}
class OverlayGeometryApp extends StatefulWidget {
const OverlayGeometryApp({Key key}) : super(key: key);
@override
OverlayGeometryAppState createState() => OverlayGeometryAppState();
}
......@@ -209,6 +211,6 @@ void main() {
accentColor: Colors.redAccent,
),
title: 'Cards',
home: OverlayGeometryApp(),
home: const OverlayGeometryApp(),
));
}
......@@ -14,6 +14,8 @@ class CardModel {
}
class PageViewApp extends StatefulWidget {
const PageViewApp({Key key}) : super(key: key);
@override
PageViewAppState createState() => PageViewAppState();
}
......@@ -146,6 +148,6 @@ void main() {
primarySwatch: Colors.blue,
accentColor: Colors.redAccent,
),
home: PageViewApp(),
home: const PageViewApp(),
));
}
......@@ -8,7 +8,7 @@ import 'package:manual_tests/overlay_geometry.dart' as overlay_geometry;
void main() {
testWidgets('Overlay geometry smoke test', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: overlay_geometry.OverlayGeometryApp()));
await tester.pumpWidget(const MaterialApp(home: overlay_geometry.OverlayGeometryApp()));
expect(find.byType(overlay_geometry.Marker), findsNothing);
await tester.tap(find.text('Card 3'));
await tester.pump();
......
......@@ -7,10 +7,12 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(FlutterView());
runApp(const FlutterView());
}
class FlutterView extends StatelessWidget {
const FlutterView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
......@@ -18,12 +20,14 @@ class FlutterView extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.grey,
),
home: MyHomePage(),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
......
......@@ -124,7 +124,7 @@ const int IMAGES = 50;
@immutable
class MyApp extends StatelessWidget {
const MyApp(this.port);
const MyApp(this.port, {Key? key}) : super(key: key);
final int port;
......
......@@ -197,6 +197,8 @@ class CalculationManager {
// This is a StatefulWidget in order to hold the CalculationManager and
// the AnimationController for the running animation.
class IsolateExampleWidget extends StatefulWidget {
const IsolateExampleWidget({Key? key}) : super(key: key);
@override
IsolateExampleState createState() => IsolateExampleState();
}
......@@ -302,5 +304,5 @@ class IsolateExampleState extends State<StatefulWidget> with SingleTickerProvide
}
void main() {
runApp(MaterialApp(home: IsolateExampleWidget()));
runApp(const MaterialApp(home: IsolateExampleWidget()));
}
......@@ -9,7 +9,7 @@ import '../widgets/gestures.dart';
void main() {
testWidgets('Tap on center change color', (WidgetTester tester) async {
await tester.pumpWidget(Directionality(
await tester.pumpWidget(const Directionality(
textDirection: TextDirection.ltr,
child: GestureDemo(),
));
......
......@@ -13,6 +13,6 @@ void main() {
});
testWidgets('Sector Sixes', (WidgetTester tester) async {
await tester.pumpWidget(SectorApp());
await tester.pumpWidget(const SectorApp());
});
}
......@@ -55,6 +55,8 @@ class _GesturePainter extends CustomPainter {
}
class GestureDemo extends StatefulWidget {
const GestureDemo({Key? key}) : super(key: key);
@override
GestureDemoState createState() => GestureDemoState();
}
......@@ -223,7 +225,7 @@ void main() {
theme: ThemeData.dark(),
home: Scaffold(
appBar: AppBar(title: const Text('Gestures Demo')),
body: GestureDemo(),
body: const GestureDemo(),
),
));
}
......@@ -16,6 +16,8 @@ RenderBoxToRenderSectorAdapter initCircle() {
}
class SectorApp extends StatefulWidget {
const SectorApp({Key? key}) : super(key: key);
@override
SectorAppState createState() => SectorAppState();
}
......@@ -163,5 +165,5 @@ class SectorAppState extends State<SectorApp> {
}
void main() {
runApp(SectorApp());
runApp(const SectorApp());
}
......@@ -5,6 +5,8 @@
import 'package:flutter/widgets.dart';
class SpinningSquare extends StatefulWidget {
const SpinningSquare({Key? key}) : super(key: key);
@override
_SpinningSquareState createState() => _SpinningSquareState();
}
......@@ -44,5 +46,5 @@ class _SpinningSquareState extends State<SpinningSquare> with SingleTickerProvid
}
void main() {
runApp(Center(child: SpinningSquare()));
runApp(const Center(child: SpinningSquare()));
}
......@@ -58,6 +58,8 @@ Widget toStyledText(String name, String text) {
Widget toPlainText(String name, String text) => Text(name + ':' + text);
class SpeakerSeparator extends StatelessWidget {
const SpeakerSeparator({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
......@@ -73,6 +75,8 @@ class SpeakerSeparator extends StatelessWidget {
}
class StyledTextDemo extends StatefulWidget {
const StyledTextDemo({Key? key}) : super(key: key);
@override
_StyledTextDemoState createState() => _StyledTextDemoState();
}
......@@ -99,7 +103,7 @@ class _StyledTextDemoState extends State<StyledTextDemo> {
.map<Widget>((List<String> nameAndText) => _toText(nameAndText[0], nameAndText[1]))
.expand((Widget line) => <Widget>[
line,
SpeakerSeparator(),
const SpeakerSeparator(),
])
.toList()..removeLast(),
),
......@@ -117,7 +121,7 @@ void main() {
),
body: Material(
color: Colors.grey.shade50,
child: StyledTextDemo(),
child: const StyledTextDemo(),
),
),
));
......
......@@ -8,6 +8,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class PlatformChannel extends StatefulWidget {
const PlatformChannel({Key? key}) : super(key: key);
@override
_PlatformChannelState createState() => _PlatformChannelState();
}
......@@ -80,5 +82,5 @@ class _PlatformChannelState extends State<PlatformChannel> {
}
void main() {
runApp(MaterialApp(home: PlatformChannel()));
runApp(const MaterialApp(home: PlatformChannel()));
}
......@@ -8,6 +8,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class PlatformChannel extends StatefulWidget {
const PlatformChannel({Key? key}) : super(key: key);
@override
_PlatformChannelState createState() => _PlatformChannelState();
}
......@@ -80,5 +82,5 @@ class _PlatformChannelState extends State<PlatformChannel> {
}
void main() {
runApp(MaterialApp(home: PlatformChannel()));
runApp(const MaterialApp(home: PlatformChannel()));
}
......@@ -8,10 +8,12 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(PlatformView());
runApp(const PlatformView());
}
class PlatformView extends StatelessWidget {
const PlatformView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
......
......@@ -123,6 +123,7 @@ class NavigationRail extends StatefulWidget {
///
/// Typically used within a [Row] that defines the [Scaffold.body] property.
const NavigationRail({
Key? key,
this.backgroundColor,
this.extended = false,
this.leading,
......@@ -147,7 +148,8 @@ class NavigationRail extends StatefulWidget {
assert(minExtendedWidth == null || minExtendedWidth > 0),
assert((minWidth == null || minExtendedWidth == null) || minExtendedWidth >= minWidth),
assert(extended != null),
assert(!extended || (labelType == null || labelType == NavigationRailLabelType.none));
assert(!extended || (labelType == null || labelType == NavigationRailLabelType.none)),
super(key: key);
/// Sets the color of the Container that holds all of the [NavigationRail]'s
/// contents.
......
......@@ -494,7 +494,7 @@ class RtlOverrideWidgetsLocalization implements WidgetsLocalizations {
}
class KeepsStateTestWidget extends StatefulWidget {
const KeepsStateTestWidget({this.navigatorKey});
const KeepsStateTestWidget({Key? key, this.navigatorKey}) : super(key: key);
final Key? navigatorKey;
......
......@@ -960,7 +960,7 @@ Widget buildNavigator({
}
class KeepsStateTestWidget extends StatefulWidget {
const KeepsStateTestWidget({this.navigatorKey});
const KeepsStateTestWidget({Key? key, this.navigatorKey}) : super(key: key);
final Key? navigatorKey;
......
......@@ -3308,7 +3308,7 @@ void main() {
});
testWidgets('Crash on dispose', (WidgetTester tester) async {
await tester.pumpWidget(Padding(padding: const EdgeInsets.only(right: 200.0), child: TabBarDemo()));
await tester.pumpWidget(const Padding(padding: EdgeInsets.only(right: 200.0), child: TabBarDemo()));
await tester.tap(find.byIcon(Icons.directions_bike));
// There was a time where this would throw an exception
// because we tried to send a notification on dispose.
......@@ -3428,6 +3428,8 @@ class _KeepAliveInkState extends State<KeepAliveInk> with AutomaticKeepAliveClie
}
class TabBarDemo extends StatelessWidget {
const TabBarDemo({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
......
......@@ -1667,7 +1667,7 @@ class DependentState extends State<DependentStatefulWidget> {
}
class SwapKeyWidget extends StatefulWidget {
const SwapKeyWidget({this.childKey}): super();
const SwapKeyWidget({Key? key, this.childKey}): super(key: key);
final Key? childKey;
@override
......
......@@ -270,7 +270,7 @@ enum WidgetState {
}
class TestStates extends StatefulWidget {
const TestStates({required this.states});
const TestStates({Key? key, required this.states}) : super(key: key);
final List<WidgetState> states;
......
......@@ -1030,13 +1030,13 @@ Route<void> _routeBuilder(BuildContext context, Object? arguments) {
Route<void> _routeFutureBuilder(BuildContext context, Object? arguments) {
return MaterialPageRoute<void>(
builder: (BuildContext context) {
return RouteFutureWidget();
return const RouteFutureWidget();
},
);
}
class PagedTestWidget extends StatelessWidget {
const PagedTestWidget({this.restorationId = 'app'});
const PagedTestWidget({Key? key, this.restorationId = 'app'}) : super(key: key);
final String restorationId;
......@@ -1044,7 +1044,7 @@ class PagedTestWidget extends StatelessWidget {
Widget build(BuildContext context) {
return RootRestorationScope(
restorationId: restorationId,
child: Directionality(
child: const Directionality(
textDirection: TextDirection.ltr,
child: PagedTestNavigator(),
),
......@@ -1053,6 +1053,8 @@ class PagedTestWidget extends StatelessWidget {
}
class PagedTestNavigator extends StatefulWidget {
const PagedTestNavigator({Key? key}) : super(key: key);
@override
State<PagedTestNavigator> createState() => PagedTestNavigatorState();
}
......@@ -1157,7 +1159,7 @@ class TestPage extends Page<void> {
}
class TestWidget extends StatelessWidget {
const TestWidget({this.restorationId = 'app'});
const TestWidget({Key? key, this.restorationId = 'app'}) : super(key: key);
final String? restorationId;
......@@ -1237,6 +1239,8 @@ class RouteWidgetState extends State<RouteWidget> with RestorationMixin {
}
class RouteFutureWidget extends StatefulWidget {
const RouteFutureWidget({Key? key}): super(key: key);
@override
State<RouteFutureWidget> createState() => RouteFutureWidgetState();
}
......
......@@ -6,6 +6,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
class TestPage extends StatelessWidget {
const TestPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
......@@ -13,12 +15,14 @@ class TestPage extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(),
home: const HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() => _HomePageState();
}
......@@ -30,7 +34,7 @@ class _HomePageState extends State<HomePage> {
barrierColor: Colors.black54,
opaque: false,
pageBuilder: (BuildContext context, _, __) {
return ModalPage();
return const ModalPage();
},
));
}
......@@ -50,6 +54,8 @@ class _HomePageState extends State<HomePage> {
}
class ModalPage extends StatelessWidget {
const ModalPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Material(
......@@ -81,7 +87,7 @@ class ModalPage extends StatelessWidget {
void main() {
testWidgets('Barriers show when using PageRouteBuilder', (WidgetTester tester) async {
await tester.pumpWidget(TestPage());
await tester.pumpWidget(const TestPage());
await tester.tap(find.byType(FloatingActionButton));
await tester.pumpAndSettle();
await expectLater(
......
......@@ -7,7 +7,7 @@ import 'package:flutter/gestures.dart';
import 'package:flutter_test/flutter_test.dart';
class ExpandingBox extends StatefulWidget {
const ExpandingBox({ required this.collapsedSize, required this.expandedSize });
const ExpandingBox({ Key? key, required this.collapsedSize, required this.expandedSize }) : super(key: key);
final double collapsedSize;
final double expandedSize;
......@@ -220,12 +220,12 @@ void main() {
});
testWidgets('expanding page views', (WidgetTester tester) async {
await tester.pumpWidget(Padding(padding: const EdgeInsets.only(right: 200.0), child: TabBarDemo()));
await tester.pumpWidget(const Padding(padding: EdgeInsets.only(right: 200.0), child: TabBarDemo()));
await tester.tap(find.text('bike'));
await tester.pump();
await tester.pump(const Duration(seconds: 1));
final Rect bike1 = tester.getRect(find.byIcon(Icons.directions_bike));
await tester.pumpWidget(Padding(padding: EdgeInsets.zero, child: TabBarDemo()));
await tester.pumpWidget(const Padding(padding: EdgeInsets.zero, child: TabBarDemo()));
final Rect bike2 = tester.getRect(find.byIcon(Icons.directions_bike));
expect(bike2.center, bike1.shift(const Offset(100.0, 0.0)).center);
});
......@@ -266,6 +266,8 @@ void main() {
}
class TabBarDemo extends StatelessWidget {
const TabBarDemo({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
......
......@@ -28,7 +28,7 @@ class Pair<T> {
/// and the other child in the bottom half. It will swap which child is on top
/// and which is on bottom every time the widget is rendered.
abstract class Swapper extends RenderObjectWidget {
const Swapper({ this.stable, this.swapper });
const Swapper({ Key? key, this.stable, this.swapper }) : super(key: key);
final Widget? stable;
final Widget? swapper;
......@@ -42,9 +42,10 @@ abstract class Swapper extends RenderObjectWidget {
class SwapperWithProperOverrides extends Swapper {
const SwapperWithProperOverrides({
Key? key,
Widget? stable,
Widget? swapper,
}) : super(stable: stable, swapper: swapper);
}) : super(key: key, stable: stable, swapper: swapper);
@override
SwapperElement createElement() => SwapperElementWithProperOverrides(this);
......@@ -52,9 +53,10 @@ class SwapperWithProperOverrides extends Swapper {
class SwapperWithNoOverrides extends Swapper {
const SwapperWithNoOverrides({
Key? key,
Widget? stable,
Widget? swapper,
}) : super(stable: stable, swapper: swapper);
}) : super(key: key, stable: stable, swapper: swapper);
@override
SwapperElement createElement() => SwapperElementWithNoOverrides(this);
......@@ -62,9 +64,10 @@ class SwapperWithNoOverrides extends Swapper {
class SwapperWithDeprecatedOverrides extends Swapper {
const SwapperWithDeprecatedOverrides({
Key? key,
Widget? stable,
Widget? swapper,
}) : super(stable: stable, swapper: swapper);
}) : super(key: key, stable: stable, swapper: swapper);
@override
SwapperElement createElement() => SwapperElementWithDeprecatedOverrides(this);
......
......@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('widget moves scopes during restore', (WidgetTester tester) async {
await tester.pumpWidget(RootRestorationScope(
await tester.pumpWidget(const RootRestorationScope(
restorationId: 'root',
child: Directionality(
textDirection: TextDirection.ltr,
......@@ -111,6 +111,8 @@ void main() {
}
class TestWidgetWithCounterChild extends StatefulWidget {
const TestWidgetWithCounterChild({Key? key}) : super(key: key);
@override
State<TestWidgetWithCounterChild> createState() => TestWidgetWithCounterChildState();
}
......@@ -159,7 +161,7 @@ class TestWidgetWithCounterChildState extends State<TestWidgetWithCounterChild>
}
class Counter extends StatefulWidget {
const Counter({this.restorationId});
const Counter({Key? key, this.restorationId}) : super(key: key);
final String? restorationId;
......@@ -200,7 +202,7 @@ class CounterState extends State<Counter> with RestorationMixin {
}
class TestWidget extends StatefulWidget {
const TestWidget({required this.restorationId});
const TestWidget({Key? key, required this.restorationId}) : super(key: key);
final String? restorationId;
......
......@@ -1658,7 +1658,7 @@ void main() {
testWidgets('child with local history can be disposed', (WidgetTester tester) async {
// Regression test: https://github.com/flutter/flutter/issues/52478
await tester.pumpWidget(MaterialApp(
await tester.pumpWidget(const MaterialApp(
home: WidgetWithLocalHistory(),
));
......@@ -1910,6 +1910,8 @@ class _TestDialogRouteWithCustomBarrierCurve<T> extends PopupRoute<T> {
}
class WidgetWithLocalHistory extends StatefulWidget {
const WidgetWithLocalHistory({Key? key}) : super(key: key);
@override
WidgetWithLocalHistoryState createState() => WidgetWithLocalHistoryState();
}
......
......@@ -116,7 +116,7 @@ void main() {
}
class PageView62209 extends StatefulWidget {
const PageView62209();
const PageView62209({Key? key}) : super(key: key);
@override
_PageView62209State createState() => _PageView62209State();
......
......@@ -169,7 +169,7 @@ Widget buildFrame({
}
class SyncLoadTest extends StatefulWidget {
const SyncLoadTest();
const SyncLoadTest({Key? key}) : super(key: key);
@override
SyncLoadTestState createState() => SyncLoadTestState();
......
......@@ -181,7 +181,7 @@ Widget _boilerplate(Widget child) {
}
class SimpleCustomSemanticsWidget extends LeafRenderObjectWidget {
const SimpleCustomSemanticsWidget(this.label);
const SimpleCustomSemanticsWidget(this.label, {Key? key}) : super(key: key);
final String label;
......
......@@ -8,6 +8,8 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart';
class CountButton extends StatefulWidget {
const CountButton({Key? key}) : super(key: key);
@override
_CountButtonState createState() => _CountButtonState();
}
......@@ -28,6 +30,8 @@ class _CountButtonState extends State<CountButton> {
}
class AnimateSample extends StatefulWidget {
const AnimateSample({Key? key}) : super(key: key);
@override
_AnimateSampleState createState() => _AnimateSampleState();
}
......@@ -62,7 +66,7 @@ class _AnimateSampleState extends State<AnimateSample>
void main() {
test('Test pump on LiveWidgetController', () async {
runApp(MaterialApp(home: Center(child: CountButton())));
runApp(const MaterialApp(home: Center(child: CountButton())));
await SchedulerBinding.instance!.endOfFrame;
final WidgetController controller =
......@@ -76,7 +80,7 @@ void main() {
});
test('Test pumpAndSettle on LiveWidgetController', () async {
runApp(MaterialApp(home: Center(child: AnimateSample())));
runApp(const MaterialApp(home: Center(child: AnimateSample())));
await SchedulerBinding.instance!.endOfFrame;
final WidgetController controller =
LiveWidgetController(WidgetsBinding.instance!);
......
......@@ -7,9 +7,11 @@ import 'package:flutter/material.dart';
// ignore_for_file: public_member_api_docs
void startApp() => runApp(MyApp());
void startApp() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
......
......@@ -7,9 +7,11 @@ import 'package:flutter/material.dart';
// ignore_for_file: public_member_api_docs
void startApp() => runApp(MyWebApp());
void startApp() => runApp(const MyWebApp());
class MyWebApp extends StatefulWidget {
const MyWebApp({Key? key}) : super(key: key);
@override
_MyWebAppState createState() => _MyWebAppState();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment