From e2e2713986d74beae8c64d15d30807b1dc1bcc38 Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Sat, 9 Oct 2021 08:30:28 +1100 Subject: [PATCH] Enforce `use_key_in_widget_constructors` and `file_names` lints (#913) * Start enforcing use_key_in_widget_constructors and file_names lints * dart format * analysis fixes * analysis fixes, pt2 * analysis fixes, part 3 * Revert platform_design (test failure) * More reverts * Notate why we aren't enforcing a lint --- .../test/widget_test.dart | 3 +-- .../books/flutter_module_books/lib/api.dart | 1 + .../pubspec.yaml | 1 - .../federated_plugin_windows/pubspec.yaml | 1 - .../linting_tool/analysis_options.yaml | 2 -- .../web_dashboard/analysis_options.yaml | 1 - experimental/web_dashboard/lib/src/app.dart | 13 +++++++----- .../lib/src/pages/dashboard.dart | 4 +++- .../web_dashboard/lib/src/pages/entries.dart | 5 ++++- .../web_dashboard/lib/src/pages/home.dart | 11 +++++----- .../web_dashboard/lib/src/pages/sign_in.dart | 6 ++++-- .../lib/src/widgets/categories_dropdown.dart | 3 ++- .../lib/src/widgets/category_chart.dart | 3 ++- .../lib/src/widgets/category_forms.dart | 5 ++++- .../lib/src/widgets/dialogs.dart | 18 +++++++++++------ .../lib/src/widgets/edit_entry.dart | 5 ++++- .../third_party/adaptive_scaffold.dart | 3 ++- platform_channels/analysis_options.yaml | 2 -- platform_channels/lib/main.dart | 20 +++++++++++-------- .../lib/src/add_pet_details.dart | 2 ++ .../lib/src/event_channel_demo.dart | 2 ++ .../lib/src/method_channel_demo.dart | 2 ++ .../lib/src/pet_list_screen.dart | 4 +++- .../lib/src/platform_image_demo.dart | 2 ++ platform_channels/test/home_page_test.dart | 2 +- .../test/src/add_pet_details_test.dart | 2 +- .../test/src/event_channel_demo_test.dart | 2 +- .../test/src/method_channel_demo_test.dart | 2 +- .../test/src/platform_image_demo_test.dart | 2 +- platform_design/analysis_options.yaml | 1 + platform_view_swift/analysis_options.yaml | 1 - platform_view_swift/lib/main.dart | 4 +++- provider_counter/analysis_options.yaml | 1 - provider_counter/lib/main.dart | 8 ++++++-- provider_counter/test/widget_test.dart | 2 +- provider_shopper/analysis_options.yaml | 1 - provider_shopper/lib/main.dart | 10 ++++++---- provider_shopper/lib/screens/cart.dart | 2 ++ provider_shopper/lib/screens/catalog.dart | 2 ++ provider_shopper/lib/screens/login.dart | 2 ++ provider_shopper/test/cart_widget_test.dart | 2 +- .../test/catalog_widget_test.dart | 2 +- provider_shopper/test/login_widget_test.dart | 4 ++-- provider_shopper/test/widget_test.dart | 2 +- testing_app/analysis_options.yaml | 2 -- testing_app/integration_test/app_test.dart | 8 ++++---- testing_app/integration_test/perf_test.dart | 4 ++-- .../integration_test/state_mgmt_test.dart | 2 +- testing_app/lib/main.dart | 8 +++++--- testing_app/lib/screens/favorites.dart | 6 +++--- testing_app/lib/screens/home.dart | 6 +++--- testing_app/test/favorites_test.dart | 2 +- testing_app/test/home_test.dart | 2 +- veggieseasons/analysis_options.yaml | 1 - veggieseasons/lib/main.dart | 4 +++- veggieseasons/lib/screens/details.dart | 6 +++--- veggieseasons/lib/widgets/close_button.dart | 2 +- veggieseasons/lib/widgets/settings_group.dart | 8 +++++--- veggieseasons/lib/widgets/trivia.dart | 2 +- veggieseasons/lib/widgets/veggie_card.dart | 7 +++++-- .../lib/widgets/veggie_headline.dart | 6 ++++-- veggieseasons/test/restoration_test.dart | 2 +- web/filipino_cuisine/analysis_options.yaml | 1 - web/filipino_cuisine/lib/cook.dart | 3 ++- web/filipino_cuisine/lib/flutter_swiper.dart | 3 ++- web/filipino_cuisine/lib/main.dart | 15 ++++++++------ .../lib/transformer_page_view.dart | 12 +++++++---- web/filipino_cuisine/pubspec.lock | 2 +- web/samples_index/analysis_options.yaml | 1 - 69 files changed, 174 insertions(+), 114 deletions(-) diff --git a/add_to_app/android_view/flutter_module_using_plugin/test/widget_test.dart b/add_to_app/android_view/flutter_module_using_plugin/test/widget_test.dart index fae080c54..72807e9b7 100644 --- a/add_to_app/android_view/flutter_module_using_plugin/test/widget_test.dart +++ b/add_to_app/android_view/flutter_module_using_plugin/test/widget_test.dart @@ -6,9 +6,8 @@ // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - import 'package:flutter_module_using_plugin/main.dart'; +import 'package:flutter_test/flutter_test.dart'; import 'package:provider/provider.dart'; class MockCounterModel extends ChangeNotifier implements CounterModel { diff --git a/add_to_app/books/flutter_module_books/lib/api.dart b/add_to_app/books/flutter_module_books/lib/api.dart index ccdc0e534..f7c941bdc 100644 --- a/add_to_app/books/flutter_module_books/lib/api.dart +++ b/add_to_app/books/flutter_module_books/lib/api.dart @@ -94,6 +94,7 @@ abstract class FlutterBookApi { if (api == null) { channel.setMessageHandler(null); } else { + // ignore: avoid_types_on_closure_parameters channel.setMessageHandler((Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.FlutterBookApi.displayBookDetails was null.'); diff --git a/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.yaml b/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.yaml index c3837ede6..c2b92296a 100644 --- a/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.yaml +++ b/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.yaml @@ -1,7 +1,6 @@ name: federated_plugin_platform_interface description: A platform interface for federated_plugin. version: 0.0.1 -author: homepage: publish_to: none diff --git a/experimental/federated_plugin/federated_plugin_windows/pubspec.yaml b/experimental/federated_plugin/federated_plugin_windows/pubspec.yaml index 3b0b65282..838e4603b 100644 --- a/experimental/federated_plugin/federated_plugin_windows/pubspec.yaml +++ b/experimental/federated_plugin/federated_plugin_windows/pubspec.yaml @@ -1,7 +1,6 @@ name: federated_plugin_windows description: Windows implementation of federated_plugin to retrieve current battery level. version: 0.0.1 -author: homepage: publish_to: none diff --git a/experimental/linting_tool/analysis_options.yaml b/experimental/linting_tool/analysis_options.yaml index 5600d266e..90eb0ad9f 100644 --- a/experimental/linting_tool/analysis_options.yaml +++ b/experimental/linting_tool/analysis_options.yaml @@ -15,10 +15,8 @@ linter: cancel_subscriptions: true close_sinks: true directives_ordering: true - file_names: false package_api_docs: true package_prefixed_library_names: true test_types_in_equals: true throw_in_finally: true unnecessary_statements: true - use_key_in_widget_constructors: false diff --git a/experimental/web_dashboard/analysis_options.yaml b/experimental/web_dashboard/analysis_options.yaml index 30ac27228..85f6fbe91 100644 --- a/experimental/web_dashboard/analysis_options.yaml +++ b/experimental/web_dashboard/analysis_options.yaml @@ -17,4 +17,3 @@ linter: test_types_in_equals: true throw_in_finally: true unnecessary_statements: true - use_key_in_widget_constructors: false diff --git a/experimental/web_dashboard/lib/src/app.dart b/experimental/web_dashboard/lib/src/app.dart index c5eed6636..07077e260 100644 --- a/experimental/web_dashboard/lib/src/app.dart +++ b/experimental/web_dashboard/lib/src/app.dart @@ -39,14 +39,16 @@ class DashboardApp extends StatefulWidget { final ApiBuilder apiBuilder; /// Runs the app using Firebase - DashboardApp.firebase() + DashboardApp.firebase({Key key}) : auth = FirebaseAuthService(), - apiBuilder = _apiBuilder; + apiBuilder = _apiBuilder, + super(key: key); /// Runs the app using mock data - DashboardApp.mock() + DashboardApp.mock({Key key}) : auth = MockAuthService(), - apiBuilder = _mockApiBuilder; + apiBuilder = _mockApiBuilder, + super(key: key); @override _DashboardAppState createState() => _DashboardAppState(); @@ -84,7 +86,8 @@ class SignInSwitcher extends StatefulWidget { const SignInSwitcher({ this.appState, this.apiBuilder, - }); + Key key, + }) : super(key: key); @override _SignInSwitcherState createState() => _SignInSwitcherState(); diff --git a/experimental/web_dashboard/lib/src/pages/dashboard.dart b/experimental/web_dashboard/lib/src/pages/dashboard.dart index 0c98bf7a1..109794adf 100644 --- a/experimental/web_dashboard/lib/src/pages/dashboard.dart +++ b/experimental/web_dashboard/lib/src/pages/dashboard.dart @@ -10,6 +10,8 @@ import '../app.dart'; import '../widgets/category_chart.dart'; class DashboardPage extends StatelessWidget { + const DashboardPage({Key key}) : super(key: key); + @override Widget build(BuildContext context) { var appState = Provider.of(context); @@ -41,7 +43,7 @@ class DashboardPage extends StatelessWidget { class Dashboard extends StatelessWidget { final List categories; - const Dashboard(this.categories); + const Dashboard(this.categories, {Key key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/experimental/web_dashboard/lib/src/pages/entries.dart b/experimental/web_dashboard/lib/src/pages/entries.dart index f3e4b55c8..edcf70841 100644 --- a/experimental/web_dashboard/lib/src/pages/entries.dart +++ b/experimental/web_dashboard/lib/src/pages/entries.dart @@ -12,6 +12,8 @@ import '../widgets/categories_dropdown.dart'; import '../widgets/dialogs.dart'; class EntriesPage extends StatefulWidget { + const EntriesPage({Key key}) : super(key: key); + @override _EntriesPageState createState() => _EntriesPageState(); } @@ -100,7 +102,8 @@ class EntryTile extends StatelessWidget { const EntryTile({ this.category, this.entry, - }); + Key key, + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/experimental/web_dashboard/lib/src/pages/home.dart b/experimental/web_dashboard/lib/src/pages/home.dart index 4213b3784..8aa9b64d5 100644 --- a/experimental/web_dashboard/lib/src/pages/home.dart +++ b/experimental/web_dashboard/lib/src/pages/home.dart @@ -14,7 +14,8 @@ class HomePage extends StatefulWidget { const HomePage({ @required this.onSignOut, - }); + Key key, + }) : super(key: key); @override _HomePageState createState() => _HomePageState(); @@ -70,7 +71,7 @@ class _HomePageState extends State { if (_pageIndex == 0) { showDialog( context: context, - builder: (context) => NewCategoryDialog(), + builder: (context) => const NewCategoryDialog(), ); return; } @@ -78,7 +79,7 @@ class _HomePageState extends State { if (_pageIndex == 1) { showDialog( context: context, - builder: (context) => NewEntryDialog(), + builder: (context) => const NewEntryDialog(), ); return; } @@ -115,11 +116,11 @@ class _HomePageState extends State { static Widget _pageAtIndex(int index) { if (index == 0) { - return DashboardPage(); + return const DashboardPage(); } if (index == 1) { - return EntriesPage(); + return const EntriesPage(); } return const Center(child: Text('Settings page')); diff --git a/experimental/web_dashboard/lib/src/pages/sign_in.dart b/experimental/web_dashboard/lib/src/pages/sign_in.dart index f91c99c4f..6ec7a635d 100644 --- a/experimental/web_dashboard/lib/src/pages/sign_in.dart +++ b/experimental/web_dashboard/lib/src/pages/sign_in.dart @@ -13,7 +13,8 @@ class SignInPage extends StatelessWidget { const SignInPage({ @required this.auth, @required this.onSuccess, - }); + Key key, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -32,7 +33,8 @@ class SignInButton extends StatefulWidget { const SignInButton({ @required this.auth, @required this.onSuccess, - }); + Key key, + }) : super(key: key); @override _SignInButtonState createState() => _SignInButtonState(); diff --git a/experimental/web_dashboard/lib/src/widgets/categories_dropdown.dart b/experimental/web_dashboard/lib/src/widgets/categories_dropdown.dart index b8daa5543..4b7632b22 100644 --- a/experimental/web_dashboard/lib/src/widgets/categories_dropdown.dart +++ b/experimental/web_dashboard/lib/src/widgets/categories_dropdown.dart @@ -16,7 +16,8 @@ class CategoryDropdown extends StatefulWidget { const CategoryDropdown({ @required this.api, @required this.onSelected, - }); + Key key, + }) : super(key: key); @override _CategoryDropdownState createState() => _CategoryDropdownState(); diff --git a/experimental/web_dashboard/lib/src/widgets/category_chart.dart b/experimental/web_dashboard/lib/src/widgets/category_chart.dart index ec83ad9a5..415723df1 100644 --- a/experimental/web_dashboard/lib/src/widgets/category_chart.dart +++ b/experimental/web_dashboard/lib/src/widgets/category_chart.dart @@ -20,7 +20,8 @@ class CategoryChart extends StatelessWidget { const CategoryChart({ @required this.category, @required this.api, - }); + Key key, + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/experimental/web_dashboard/lib/src/widgets/category_forms.dart b/experimental/web_dashboard/lib/src/widgets/category_forms.dart index 1c2ad0921..bd3c568be 100644 --- a/experimental/web_dashboard/lib/src/widgets/category_forms.dart +++ b/experimental/web_dashboard/lib/src/widgets/category_forms.dart @@ -8,6 +8,8 @@ import 'package:web_dashboard/src/api/api.dart'; import 'package:web_dashboard/src/app.dart'; class NewCategoryForm extends StatefulWidget { + const NewCategoryForm({Key key}) : super(key: key); + @override _NewCategoryFormState createState() => _NewCategoryFormState(); } @@ -37,7 +39,8 @@ class EditCategoryForm extends StatefulWidget { const EditCategoryForm({ @required this.category, @required this.onDone, - }); + Key key, + }) : super(key: key); @override _EditCategoryFormState createState() => _EditCategoryFormState(); diff --git a/experimental/web_dashboard/lib/src/widgets/dialogs.dart b/experimental/web_dashboard/lib/src/widgets/dialogs.dart index 0ec805840..170319b8f 100644 --- a/experimental/web_dashboard/lib/src/widgets/dialogs.dart +++ b/experimental/web_dashboard/lib/src/widgets/dialogs.dart @@ -11,10 +11,12 @@ import '../app.dart'; import 'edit_entry.dart'; class NewCategoryDialog extends StatelessWidget { + const NewCategoryDialog({Key key}) : super(key: key); + @override Widget build(BuildContext context) { - return SimpleDialog( - title: const Text('New Category'), + return const SimpleDialog( + title: Text('New Category'), children: [ NewCategoryForm(), ], @@ -27,7 +29,8 @@ class EditCategoryDialog extends StatelessWidget { const EditCategoryDialog({ @required this.category, - }); + Key key, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -51,6 +54,8 @@ class EditCategoryDialog extends StatelessWidget { } class NewEntryDialog extends StatefulWidget { + const NewEntryDialog({Key key}) : super(key: key); + @override _NewEntryDialogState createState() => _NewEntryDialogState(); } @@ -58,8 +63,8 @@ class NewEntryDialog extends StatefulWidget { class _NewEntryDialogState extends State { @override Widget build(BuildContext context) { - return SimpleDialog( - title: const Text('New Entry'), + return const SimpleDialog( + title: Text('New Entry'), children: [ NewEntryForm(), ], @@ -74,7 +79,8 @@ class EditEntryDialog extends StatelessWidget { const EditEntryDialog({ this.category, this.entry, - }); + Key key, + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/experimental/web_dashboard/lib/src/widgets/edit_entry.dart b/experimental/web_dashboard/lib/src/widgets/edit_entry.dart index c81500667..4a6365c8e 100644 --- a/experimental/web_dashboard/lib/src/widgets/edit_entry.dart +++ b/experimental/web_dashboard/lib/src/widgets/edit_entry.dart @@ -11,6 +11,8 @@ import '../app.dart'; import 'categories_dropdown.dart'; class NewEntryForm extends StatefulWidget { + const NewEntryForm({Key key}) : super(key: key); + @override _NewEntryFormState createState() => _NewEntryFormState(); } @@ -58,7 +60,8 @@ class EditEntryForm extends StatefulWidget { const EditEntryForm({ @required this.entry, @required this.onDone, - }); + Key key, + }) : super(key: key); @override _EditEntryFormState createState() => _EditEntryFormState(); diff --git a/experimental/web_dashboard/lib/src/widgets/third_party/adaptive_scaffold.dart b/experimental/web_dashboard/lib/src/widgets/third_party/adaptive_scaffold.dart index ddb3e63e8..30b065821 100644 --- a/experimental/web_dashboard/lib/src/widgets/third_party/adaptive_scaffold.dart +++ b/experimental/web_dashboard/lib/src/widgets/third_party/adaptive_scaffold.dart @@ -43,7 +43,8 @@ class AdaptiveScaffold extends StatefulWidget { @required this.destinations, this.onNavigationIndexChange, this.floatingActionButton, - }); + Key key, + }) : super(key: key); @override _AdaptiveScaffoldState createState() => _AdaptiveScaffoldState(); diff --git a/platform_channels/analysis_options.yaml b/platform_channels/analysis_options.yaml index be4f27226..85f6fbe91 100644 --- a/platform_channels/analysis_options.yaml +++ b/platform_channels/analysis_options.yaml @@ -12,10 +12,8 @@ linter: cancel_subscriptions: true close_sinks: true directives_ordering: true - file_names: false package_api_docs: true package_prefixed_library_names: true test_types_in_equals: true throw_in_finally: true unnecessary_statements: true - use_key_in_widget_constructors: false diff --git a/platform_channels/lib/main.dart b/platform_channels/lib/main.dart index a33634e81..c45a3b10f 100644 --- a/platform_channels/lib/main.dart +++ b/platform_channels/lib/main.dart @@ -10,19 +10,21 @@ import 'package:platform_channels/src/pet_list_screen.dart'; import 'package:platform_channels/src/platform_image_demo.dart'; void main() { - runApp(PlatformChannelSample()); + runApp(const PlatformChannelSample()); } class PlatformChannelSample extends StatelessWidget { + const PlatformChannelSample({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return MaterialApp( routes: { - '/methodChannelDemo': (context) => MethodChannelDemo(), - '/eventChannelDemo': (context) => EventChannelDemo(), - '/platformImageDemo': (context) => PlatformImageDemo(), - '/petListScreen': (context) => PetListScreen(), - '/addPetDetails': (context) => AddPetDetails(), + '/methodChannelDemo': (context) => const MethodChannelDemo(), + '/eventChannelDemo': (context) => const EventChannelDemo(), + '/platformImageDemo': (context) => const PlatformImageDemo(), + '/petListScreen': (context) => const PetListScreen(), + '/addPetDetails': (context) => const AddPetDetails(), }, title: 'Platform Channel Sample', theme: ThemeData( @@ -30,7 +32,7 @@ class PlatformChannelSample extends StatelessWidget { backgroundColor: Colors.blue[500], ), ), - home: HomePage(), + home: const HomePage(), ); } } @@ -62,6 +64,8 @@ List demoList = [ ]; class HomePage extends StatelessWidget { + const HomePage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( @@ -79,7 +83,7 @@ class HomePage extends StatelessWidget { class DemoTile extends StatelessWidget { final DemoInfo demoInfo; - const DemoTile(this.demoInfo); + const DemoTile(this.demoInfo, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/platform_channels/lib/src/add_pet_details.dart b/platform_channels/lib/src/add_pet_details.dart index fe9756f08..859c7d5c9 100644 --- a/platform_channels/lib/src/add_pet_details.dart +++ b/platform_channels/lib/src/add_pet_details.dart @@ -10,6 +10,8 @@ import 'package:platform_channels/src/pet_list_message_channel.dart'; /// The widget uses [TextField] and [RadioListTile] to take the [PetDetails.breed] and /// [PetDetails.petType] from the user respectively. class AddPetDetails extends StatefulWidget { + const AddPetDetails({Key? key}) : super(key: key); + @override _AddPetDetailsState createState() => _AddPetDetailsState(); } diff --git a/platform_channels/lib/src/event_channel_demo.dart b/platform_channels/lib/src/event_channel_demo.dart index 0f84f3ae1..1b2c16357 100644 --- a/platform_channels/lib/src/event_channel_demo.dart +++ b/platform_channels/lib/src/event_channel_demo.dart @@ -14,6 +14,8 @@ import 'package:platform_channels/src/accelerometer_event_channel.dart'; /// [Text] widgets to display the value of [AccelerometerReadings.x], /// [AccelerometerReadings.y], and [AccelerometerReadings.z] respectively. class EventChannelDemo extends StatelessWidget { + const EventChannelDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { final textStyle = Theme.of(context).textTheme.headline5; diff --git a/platform_channels/lib/src/method_channel_demo.dart b/platform_channels/lib/src/method_channel_demo.dart index d1389c736..221dfb1cf 100644 --- a/platform_channels/lib/src/method_channel_demo.dart +++ b/platform_channels/lib/src/method_channel_demo.dart @@ -10,6 +10,8 @@ import 'package:platform_channels/src/counter_method_channel.dart'; /// It has two [ElevatedButton]s to increment and decrement the value of /// [count], and a [Text] widget to display its value. class MethodChannelDemo extends StatefulWidget { + const MethodChannelDemo({Key? key}) : super(key: key); + @override _MethodChannelDemoState createState() => _MethodChannelDemoState(); } diff --git a/platform_channels/lib/src/pet_list_screen.dart b/platform_channels/lib/src/pet_list_screen.dart index f7861afda..1a5444f39 100644 --- a/platform_channels/lib/src/pet_list_screen.dart +++ b/platform_channels/lib/src/pet_list_screen.dart @@ -9,6 +9,8 @@ import 'package:platform_channels/src/pet_list_message_channel.dart'; /// Demonstrates how to use [BasicMessageChannel] to send & receive the platform /// Message. class PetListScreen extends StatefulWidget { + const PetListScreen({Key? key}) : super(key: key); + @override _PetListScreenState createState() => _PetListScreenState(); } @@ -59,7 +61,7 @@ class _PetListScreenState extends State { class BuildPetList extends StatelessWidget { final List petList; - const BuildPetList(this.petList); + const BuildPetList(this.petList, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/platform_channels/lib/src/platform_image_demo.dart b/platform_channels/lib/src/platform_image_demo.dart index 593026daf..ce649ba8a 100644 --- a/platform_channels/lib/src/platform_image_demo.dart +++ b/platform_channels/lib/src/platform_image_demo.dart @@ -13,6 +13,8 @@ import 'package:platform_channels/src/image_basic_message_channel.dart'; /// The widget uses [Image.memory] to display the image obtained from the /// platform. class PlatformImageDemo extends StatefulWidget { + const PlatformImageDemo({Key? key}) : super(key: key); + @override _PlatformImageDemoState createState() => _PlatformImageDemoState(); } diff --git a/platform_channels/test/home_page_test.dart b/platform_channels/test/home_page_test.dart index 55d4d1fda..0a033956c 100644 --- a/platform_channels/test/home_page_test.dart +++ b/platform_channels/test/home_page_test.dart @@ -9,7 +9,7 @@ import 'package:platform_channels/main.dart'; void main() { group('HomePage tests', () { testWidgets('HomePage has multiple Text widgets', (tester) async { - await tester.pumpWidget(MaterialApp( + await tester.pumpWidget(const MaterialApp( home: HomePage(), )); diff --git a/platform_channels/test/src/add_pet_details_test.dart b/platform_channels/test/src/add_pet_details_test.dart index fc2db28bb..0689fc3a1 100644 --- a/platform_channels/test/src/add_pet_details_test.dart +++ b/platform_channels/test/src/add_pet_details_test.dart @@ -20,7 +20,7 @@ void main() { }); testWidgets('Enter pet details', (tester) async { - await tester.pumpWidget(MaterialApp(home: AddPetDetails())); + await tester.pumpWidget(const MaterialApp(home: AddPetDetails())); // Enter the breed of cat. await tester.enterText(find.byType(TextField), 'Persian'); diff --git a/platform_channels/test/src/event_channel_demo_test.dart b/platform_channels/test/src/event_channel_demo_test.dart index c79f4bba2..1de93ed43 100644 --- a/platform_channels/test/src/event_channel_demo_test.dart +++ b/platform_channels/test/src/event_channel_demo_test.dart @@ -49,7 +49,7 @@ void main() { testWidgets('EventChannel AccelerometerReadings Stream test', (tester) async { - await tester.pumpWidget(MaterialApp( + await tester.pumpWidget(const MaterialApp( home: EventChannelDemo(), )); diff --git a/platform_channels/test/src/method_channel_demo_test.dart b/platform_channels/test/src/method_channel_demo_test.dart index 2cb743b1a..c94f5b751 100644 --- a/platform_channels/test/src/method_channel_demo_test.dart +++ b/platform_channels/test/src/method_channel_demo_test.dart @@ -26,7 +26,7 @@ void main() { }); testWidgets('MethodChannelDemo count test', (tester) async { - await tester.pumpWidget(MaterialApp( + await tester.pumpWidget(const MaterialApp( home: MethodChannelDemo(), )); diff --git a/platform_channels/test/src/platform_image_demo_test.dart b/platform_channels/test/src/platform_image_demo_test.dart index d5d736b78..aa7e8dab1 100644 --- a/platform_channels/test/src/platform_image_demo_test.dart +++ b/platform_channels/test/src/platform_image_demo_test.dart @@ -20,7 +20,7 @@ void main() { }); testWidgets('Platform Image test', (tester) async { - await tester.pumpWidget(MaterialApp( + await tester.pumpWidget(const MaterialApp( home: PlatformImageDemo(), )); diff --git a/platform_design/analysis_options.yaml b/platform_design/analysis_options.yaml index 30ac27228..2d21f645a 100644 --- a/platform_design/analysis_options.yaml +++ b/platform_design/analysis_options.yaml @@ -17,4 +17,5 @@ linter: test_types_in_equals: true throw_in_finally: true unnecessary_statements: true + # Tests fail if we enforce `use_key_in_widget_constructors` use_key_in_widget_constructors: false diff --git a/platform_view_swift/analysis_options.yaml b/platform_view_swift/analysis_options.yaml index 30ac27228..85f6fbe91 100644 --- a/platform_view_swift/analysis_options.yaml +++ b/platform_view_swift/analysis_options.yaml @@ -17,4 +17,3 @@ linter: test_types_in_equals: true throw_in_finally: true unnecessary_statements: true - use_key_in_widget_constructors: false diff --git a/platform_view_swift/lib/main.dart b/platform_view_swift/lib/main.dart index 6b0eea99c..305918000 100644 --- a/platform_view_swift/lib/main.dart +++ b/platform_view_swift/lib/main.dart @@ -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( diff --git a/provider_counter/analysis_options.yaml b/provider_counter/analysis_options.yaml index 30ac27228..85f6fbe91 100644 --- a/provider_counter/analysis_options.yaml +++ b/provider_counter/analysis_options.yaml @@ -17,4 +17,3 @@ linter: test_types_in_equals: true throw_in_finally: true unnecessary_statements: true - use_key_in_widget_constructors: false diff --git a/provider_counter/lib/main.dart b/provider_counter/lib/main.dart index 6b3dec60e..e2f55e89d 100644 --- a/provider_counter/lib/main.dart +++ b/provider_counter/lib/main.dart @@ -18,7 +18,7 @@ void main() { // can own Counter's lifecycle, making sure to call `dispose` // when not needed anymore. create: (context) => Counter(), - child: MyApp(), + child: const MyApp(), ), ); } @@ -37,6 +37,8 @@ class Counter with ChangeNotifier { } class MyApp extends StatelessWidget { + const MyApp({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return MaterialApp( @@ -44,12 +46,14 @@ class MyApp extends StatelessWidget { theme: ThemeData( primarySwatch: Colors.blue, ), - home: MyHomePage(), + home: const MyHomePage(), ); } } class MyHomePage extends StatelessWidget { + const MyHomePage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( diff --git a/provider_counter/test/widget_test.dart b/provider_counter/test/widget_test.dart index 105b6eb9a..4e18e3c5e 100644 --- a/provider_counter/test/widget_test.dart +++ b/provider_counter/test/widget_test.dart @@ -13,7 +13,7 @@ void main() { await tester.pumpWidget( ChangeNotifierProvider( create: (context) => Counter(), - child: MyApp(), + child: const MyApp(), ), ); diff --git a/provider_shopper/analysis_options.yaml b/provider_shopper/analysis_options.yaml index 30ac27228..85f6fbe91 100644 --- a/provider_shopper/analysis_options.yaml +++ b/provider_shopper/analysis_options.yaml @@ -17,4 +17,3 @@ linter: test_types_in_equals: true throw_in_finally: true unnecessary_statements: true - use_key_in_widget_constructors: false diff --git a/provider_shopper/lib/main.dart b/provider_shopper/lib/main.dart index df03d0dd9..5c4d7fa08 100644 --- a/provider_shopper/lib/main.dart +++ b/provider_shopper/lib/main.dart @@ -12,10 +12,12 @@ import 'package:provider_shopper/screens/catalog.dart'; import 'package:provider_shopper/screens/login.dart'; void main() { - runApp(MyApp()); + runApp(const MyApp()); } class MyApp extends StatelessWidget { + const MyApp({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { // Using MultiProvider is convenient when providing multiple objects. @@ -41,9 +43,9 @@ class MyApp extends StatelessWidget { theme: appTheme, initialRoute: '/', routes: { - '/': (context) => MyLogin(), - '/catalog': (context) => MyCatalog(), - '/cart': (context) => MyCart(), + '/': (context) => const MyLogin(), + '/catalog': (context) => const MyCatalog(), + '/cart': (context) => const MyCart(), }, ), ); diff --git a/provider_shopper/lib/screens/cart.dart b/provider_shopper/lib/screens/cart.dart index 75d76f158..53bbd02a5 100644 --- a/provider_shopper/lib/screens/cart.dart +++ b/provider_shopper/lib/screens/cart.dart @@ -7,6 +7,8 @@ import 'package:provider/provider.dart'; import 'package:provider_shopper/models/cart.dart'; class MyCart extends StatelessWidget { + const MyCart({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( diff --git a/provider_shopper/lib/screens/catalog.dart b/provider_shopper/lib/screens/catalog.dart index 4b765324d..3580469b8 100644 --- a/provider_shopper/lib/screens/catalog.dart +++ b/provider_shopper/lib/screens/catalog.dart @@ -8,6 +8,8 @@ import 'package:provider_shopper/models/cart.dart'; import 'package:provider_shopper/models/catalog.dart'; class MyCatalog extends StatelessWidget { + const MyCatalog({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( diff --git a/provider_shopper/lib/screens/login.dart b/provider_shopper/lib/screens/login.dart index 46343ca77..fd71bab19 100644 --- a/provider_shopper/lib/screens/login.dart +++ b/provider_shopper/lib/screens/login.dart @@ -5,6 +5,8 @@ import 'package:flutter/material.dart'; class MyLogin extends StatelessWidget { + const MyLogin({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( diff --git a/provider_shopper/test/cart_widget_test.dart b/provider_shopper/test/cart_widget_test.dart index ed8379379..3f5dd00e4 100644 --- a/provider_shopper/test/cart_widget_test.dart +++ b/provider_shopper/test/cart_widget_test.dart @@ -24,7 +24,7 @@ Widget createCartScreen() => MultiProvider( }, ), ], - child: MaterialApp( + child: const MaterialApp( home: MyCart(), ), ); diff --git a/provider_shopper/test/catalog_widget_test.dart b/provider_shopper/test/catalog_widget_test.dart index f8419098f..129a30fae 100644 --- a/provider_shopper/test/catalog_widget_test.dart +++ b/provider_shopper/test/catalog_widget_test.dart @@ -21,7 +21,7 @@ Widget createCatalogScreen() => MultiProvider( }, ), ], - child: MaterialApp( + child: const MaterialApp( home: MyCatalog(), ), ); diff --git a/provider_shopper/test/login_widget_test.dart b/provider_shopper/test/login_widget_test.dart index b2aa493ef..c06e9d5bc 100644 --- a/provider_shopper/test/login_widget_test.dart +++ b/provider_shopper/test/login_widget_test.dart @@ -26,8 +26,8 @@ void main() { child: MaterialApp( initialRoute: '/', routes: { - '/': (context) => MyLogin(), - '/catalog': (context) => MyCatalog(), + '/': (context) => const MyLogin(), + '/catalog': (context) => const MyCatalog(), }, ), )); diff --git a/provider_shopper/test/widget_test.dart b/provider_shopper/test/widget_test.dart index 96a33c8f6..fba90c8a4 100644 --- a/provider_shopper/test/widget_test.dart +++ b/provider_shopper/test/widget_test.dart @@ -9,7 +9,7 @@ import 'package:provider_shopper/main.dart'; void main() { testWidgets('smoke test', (tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); + await tester.pumpWidget(const MyApp()); // Navigating through login page. await tester.tap(find.text('ENTER')); diff --git a/testing_app/analysis_options.yaml b/testing_app/analysis_options.yaml index be4f27226..85f6fbe91 100644 --- a/testing_app/analysis_options.yaml +++ b/testing_app/analysis_options.yaml @@ -12,10 +12,8 @@ linter: cancel_subscriptions: true close_sinks: true directives_ordering: true - file_names: false package_api_docs: true package_prefixed_library_names: true test_types_in_equals: true throw_in_finally: true unnecessary_statements: true - use_key_in_widget_constructors: false diff --git a/testing_app/integration_test/app_test.dart b/testing_app/integration_test/app_test.dart index b97825c6d..e3c5bfa77 100644 --- a/testing_app/integration_test/app_test.dart +++ b/testing_app/integration_test/app_test.dart @@ -12,7 +12,7 @@ void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); testWidgets('Finding an item in the list', (tester) async { - await tester.pumpWidget(TestingApp()); + await tester.pumpWidget(const TestingApp()); // Create variables for finders that are used multiple times. final itemFinder = find.byKey(const ValueKey('text_25')); @@ -28,7 +28,7 @@ void main() { }); testWidgets('Testing IconButtons', (tester) async { - await tester.pumpWidget(TestingApp()); + await tester.pumpWidget(const TestingApp()); // Create a finder for the icon. final iconFinder = find.byKey(const ValueKey('icon_0')); @@ -51,7 +51,7 @@ void main() { testWidgets('Verifying whether item gets added to favorites', (tester) async { - await tester.pumpWidget(TestingApp()); + await tester.pumpWidget(const TestingApp()); // Add item to favorites. await tester.tap(find.byKey(const ValueKey('icon_5'))); @@ -71,7 +71,7 @@ void main() { }); testWidgets('Testing remove button', (tester) async { - await tester.pumpWidget(TestingApp()); + await tester.pumpWidget(const TestingApp()); // Add item to favorites. await tester.tap(find.byKey(const ValueKey('icon_5'))); diff --git a/testing_app/integration_test/perf_test.dart b/testing_app/integration_test/perf_test.dart index 88a2c8b40..73d12b8e9 100644 --- a/testing_app/integration_test/perf_test.dart +++ b/testing_app/integration_test/perf_test.dart @@ -17,7 +17,7 @@ void main() { binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive; testWidgets('Scrolling test', (tester) async { - await tester.pumpWidget(TestingApp()); + await tester.pumpWidget(const TestingApp()); // Create variables for finders that are used multiple times. final listFinder = find.byType(ListView); @@ -49,7 +49,7 @@ void main() { }); testWidgets('Favorites operations test', (tester) async { - await tester.pumpWidget(TestingApp()); + await tester.pumpWidget(const TestingApp()); // Record the performance summary as operations are performed // on the favorites list. diff --git a/testing_app/integration_test/state_mgmt_test.dart b/testing_app/integration_test/state_mgmt_test.dart index 52f32b6d7..cc0b6f70d 100644 --- a/testing_app/integration_test/state_mgmt_test.dart +++ b/testing_app/integration_test/state_mgmt_test.dart @@ -16,7 +16,7 @@ Widget createFavoritesScreen() => ChangeNotifierProvider( favoritesList = Favorites(); return favoritesList; }, - child: MaterialApp( + child: const MaterialApp( home: FavoritesPage(), ), ); diff --git a/testing_app/lib/main.dart b/testing_app/lib/main.dart index 46cf61ab5..904b24e0d 100644 --- a/testing_app/lib/main.dart +++ b/testing_app/lib/main.dart @@ -9,10 +9,12 @@ import 'package:testing_app/screens/favorites.dart'; import 'package:testing_app/screens/home.dart'; void main() { - runApp(TestingApp()); + runApp(const TestingApp()); } class TestingApp extends StatelessWidget { + const TestingApp({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return ChangeNotifierProvider( @@ -24,8 +26,8 @@ class TestingApp extends StatelessWidget { visualDensity: VisualDensity.adaptivePlatformDensity, ), routes: { - HomePage.routeName: (context) => HomePage(), - FavoritesPage.routeName: (context) => FavoritesPage(), + HomePage.routeName: (context) => const HomePage(), + FavoritesPage.routeName: (context) => const FavoritesPage(), }, initialRoute: HomePage.routeName, ), diff --git a/testing_app/lib/screens/favorites.dart b/testing_app/lib/screens/favorites.dart index a0ae28a5d..46e722b6c 100644 --- a/testing_app/lib/screens/favorites.dart +++ b/testing_app/lib/screens/favorites.dart @@ -9,6 +9,8 @@ import 'package:testing_app/models/favorites.dart'; class FavoritesPage extends StatelessWidget { static String routeName = '/favorites_page'; + const FavoritesPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( @@ -34,9 +36,7 @@ class FavoritesPage extends StatelessWidget { class FavoriteItemTile extends StatelessWidget { final int itemNo; - const FavoriteItemTile( - this.itemNo, - ); + const FavoriteItemTile(this.itemNo, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/testing_app/lib/screens/home.dart b/testing_app/lib/screens/home.dart index 15f2074dd..88de68538 100644 --- a/testing_app/lib/screens/home.dart +++ b/testing_app/lib/screens/home.dart @@ -10,6 +10,8 @@ import 'package:testing_app/screens/favorites.dart'; class HomePage extends StatelessWidget { static String routeName = '/'; + const HomePage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( @@ -40,9 +42,7 @@ class HomePage extends StatelessWidget { class ItemTile extends StatelessWidget { final int itemNo; - const ItemTile( - this.itemNo, - ); + const ItemTile(this.itemNo, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/testing_app/test/favorites_test.dart b/testing_app/test/favorites_test.dart index bb58fe9e9..ea5d73e77 100644 --- a/testing_app/test/favorites_test.dart +++ b/testing_app/test/favorites_test.dart @@ -15,7 +15,7 @@ Widget createFavoritesScreen() => ChangeNotifierProvider( favoritesList = Favorites(); return favoritesList; }, - child: MaterialApp( + child: const MaterialApp( home: FavoritesPage(), ), ); diff --git a/testing_app/test/home_test.dart b/testing_app/test/home_test.dart index 52d758111..1808cc126 100644 --- a/testing_app/test/home_test.dart +++ b/testing_app/test/home_test.dart @@ -10,7 +10,7 @@ import 'package:testing_app/screens/home.dart'; Widget createHomeScreen() => ChangeNotifierProvider( create: (context) => Favorites(), - child: MaterialApp( + child: const MaterialApp( home: HomePage(), ), ); diff --git a/veggieseasons/analysis_options.yaml b/veggieseasons/analysis_options.yaml index 30ac27228..85f6fbe91 100644 --- a/veggieseasons/analysis_options.yaml +++ b/veggieseasons/analysis_options.yaml @@ -17,4 +17,3 @@ linter: test_types_in_equals: true throw_in_finally: true unnecessary_statements: true - use_key_in_widget_constructors: false diff --git a/veggieseasons/lib/main.dart b/veggieseasons/lib/main.dart index de6d9e439..e993ff29d 100644 --- a/veggieseasons/lib/main.dart +++ b/veggieseasons/lib/main.dart @@ -18,7 +18,7 @@ void main() { ]); runApp( - RootRestorationScope( + const RootRestorationScope( restorationId: 'root', child: VeggieApp(), ), @@ -26,6 +26,8 @@ void main() { } class VeggieApp extends StatefulWidget { + const VeggieApp({Key key}) : super(key: key); + @override State createState() => _VeggieAppState(); } diff --git a/veggieseasons/lib/screens/details.dart b/veggieseasons/lib/screens/details.dart index 6a4132a3f..283fb2c43 100644 --- a/veggieseasons/lib/screens/details.dart +++ b/veggieseasons/lib/screens/details.dart @@ -13,7 +13,7 @@ import 'package:veggieseasons/widgets/close_button.dart'; import 'package:veggieseasons/widgets/trivia.dart'; class ServingInfoChart extends StatelessWidget { - const ServingInfoChart(this.veggie, this.prefs); + const ServingInfoChart(this.veggie, this.prefs, {Key key}) : super(key: key); final Veggie veggie; @@ -158,7 +158,7 @@ class ServingInfoChart extends StatelessWidget { class InfoView extends StatelessWidget { final int id; - const InfoView(this.id); + const InfoView(this.id, {Key key}) : super(key: key); @override Widget build(BuildContext context) { @@ -239,7 +239,7 @@ class DetailsScreen extends StatefulWidget { final int id; final String restorationId; - const DetailsScreen({this.id, this.restorationId}); + const DetailsScreen({this.id, this.restorationId, Key key}) : super(key: key); static String show(NavigatorState navigator, int veggieId) { return navigator.restorablePush(_routeBuilder, arguments: veggieId); diff --git a/veggieseasons/lib/widgets/close_button.dart b/veggieseasons/lib/widgets/close_button.dart index 9cd63b9f0..0c7bde80a 100644 --- a/veggieseasons/lib/widgets/close_button.dart +++ b/veggieseasons/lib/widgets/close_button.dart @@ -80,7 +80,7 @@ class _ColorChangingIconState /// A simple "close this modal" button that invokes a callback when pressed. class CloseButton extends StatefulWidget { - const CloseButton(this.onPressed); + const CloseButton(this.onPressed, {Key key}) : super(key: key); final VoidCallback onPressed; diff --git a/veggieseasons/lib/widgets/settings_group.dart b/veggieseasons/lib/widgets/settings_group.dart index 49827fc4d..37b11e613 100644 --- a/veggieseasons/lib/widgets/settings_group.dart +++ b/veggieseasons/lib/widgets/settings_group.dart @@ -14,7 +14,7 @@ import 'settings_item.dart'; // See https://github.com/flutter/flutter/projects/29 for more info. class SettingsGroupHeader extends StatelessWidget { - const SettingsGroupHeader(this.title); + const SettingsGroupHeader(this.title, {Key key}) : super(key: key); final String title; @@ -35,7 +35,7 @@ class SettingsGroupHeader extends StatelessWidget { } class SettingsGroupFooter extends StatelessWidget { - const SettingsGroupFooter(this.title); + const SettingsGroupFooter(this.title, {Key key}) : super(key: key); final String title; @@ -58,8 +58,10 @@ class SettingsGroup extends StatelessWidget { @required this.items, this.header, this.footer, + Key key, }) : assert(items != null), - assert(items.isNotEmpty); + assert(items.isNotEmpty), + super(key: key); final List items; final Widget header; diff --git a/veggieseasons/lib/widgets/trivia.dart b/veggieseasons/lib/widgets/trivia.dart index 7472477c6..967c11e13 100644 --- a/veggieseasons/lib/widgets/trivia.dart +++ b/veggieseasons/lib/widgets/trivia.dart @@ -11,7 +11,7 @@ class TriviaView extends StatefulWidget { final int id; final String restorationId; - const TriviaView({this.id, this.restorationId}); + const TriviaView({this.id, this.restorationId, Key key}) : super(key: key); @override _TriviaViewState createState() => _TriviaViewState(); diff --git a/veggieseasons/lib/widgets/veggie_card.dart b/veggieseasons/lib/widgets/veggie_card.dart index 01bc2b3e7..9c072e2dc 100644 --- a/veggieseasons/lib/widgets/veggie_card.dart +++ b/veggieseasons/lib/widgets/veggie_card.dart @@ -14,7 +14,8 @@ class FrostyBackground extends StatelessWidget { this.color, this.intensity = 25, this.child, - }); + Key key, + }) : super(key: key); final Color color; final double intensity; @@ -105,7 +106,9 @@ class _PressableCardState extends State { } class VeggieCard extends StatelessWidget { - const VeggieCard(this.veggie, this.isInSeason, this.isPreferredCategory); + const VeggieCard(this.veggie, this.isInSeason, this.isPreferredCategory, + {Key key}) + : super(key: key); /// Veggie to be displayed by the card. final Veggie veggie; diff --git a/veggieseasons/lib/widgets/veggie_headline.dart b/veggieseasons/lib/widgets/veggie_headline.dart index 8144c21ea..22aa37192 100644 --- a/veggieseasons/lib/widgets/veggie_headline.dart +++ b/veggieseasons/lib/widgets/veggie_headline.dart @@ -12,7 +12,9 @@ class ZoomClipAssetImage extends StatelessWidget { {@required this.zoom, this.height, this.width, - @required this.imageAsset}); + @required this.imageAsset, + Key key}) + : super(key: key); final double zoom; final double height; @@ -43,7 +45,7 @@ class ZoomClipAssetImage extends StatelessWidget { class VeggieHeadline extends StatelessWidget { final Veggie veggie; - const VeggieHeadline(this.veggie); + const VeggieHeadline(this.veggie, {Key key}) : super(key: key); List _buildSeasonDots(List seasons) { var widgets = []; diff --git a/veggieseasons/test/restoration_test.dart b/veggieseasons/test/restoration_test.dart index 4472f42ac..9b9231ac2 100644 --- a/veggieseasons/test/restoration_test.dart +++ b/veggieseasons/test/restoration_test.dart @@ -16,7 +16,7 @@ void main() { AppState.debugCurrentSeason = Season.autumn; await tester.pumpWidget( - RootRestorationScope( + const RootRestorationScope( restorationId: 'root', child: VeggieApp(), ), diff --git a/web/filipino_cuisine/analysis_options.yaml b/web/filipino_cuisine/analysis_options.yaml index 30ac27228..85f6fbe91 100644 --- a/web/filipino_cuisine/analysis_options.yaml +++ b/web/filipino_cuisine/analysis_options.yaml @@ -17,4 +17,3 @@ linter: test_types_in_equals: true throw_in_finally: true unnecessary_statements: true - use_key_in_widget_constructors: false diff --git a/web/filipino_cuisine/lib/cook.dart b/web/filipino_cuisine/lib/cook.dart index 8c4093e44..691e1a233 100644 --- a/web/filipino_cuisine/lib/cook.dart +++ b/web/filipino_cuisine/lib/cook.dart @@ -5,7 +5,8 @@ class Cook extends StatefulWidget { final String? img; final String? nme; - const Cook(this.dr, this.img, this.nme); + const Cook(this.dr, this.img, this.nme, {Key? key}) : super(key: key); + @override CState createState() => CState(); } diff --git a/web/filipino_cuisine/lib/flutter_swiper.dart b/web/filipino_cuisine/lib/flutter_swiper.dart index 9fee58e5b..318ce4168 100644 --- a/web/filipino_cuisine/lib/flutter_swiper.dart +++ b/web/filipino_cuisine/lib/flutter_swiper.dart @@ -1423,7 +1423,8 @@ class SwiperPluginView extends StatelessWidget { final SwiperPlugin plugin; final SwiperPluginConfig config; - const SwiperPluginView(this.plugin, this.config); + const SwiperPluginView(this.plugin, this.config, {Key? key}) + : super(key: key); @override Widget build(BuildContext context) { diff --git a/web/filipino_cuisine/lib/main.dart b/web/filipino_cuisine/lib/main.dart index 2876cf847..51582e1ee 100644 --- a/web/filipino_cuisine/lib/main.dart +++ b/web/filipino_cuisine/lib/main.dart @@ -5,16 +5,17 @@ import 'package:http/http.dart' as http; import 'cook.dart'; import 'flutter_swiper.dart'; -void main() => runApp(MyApp()); +void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { - final _themeData = ThemeData( - brightness: Brightness.light, - iconTheme: const IconThemeData(color: Colors.red), - ); + const MyApp({Key? key}) : super(key: key); @override Widget build(context) { + final _themeData = ThemeData( + brightness: Brightness.light, + iconTheme: const IconThemeData(color: Colors.red), + ); return MaterialApp( theme: _themeData.copyWith( colorScheme: _themeData.colorScheme.copyWith( @@ -22,11 +23,13 @@ class MyApp extends StatelessWidget { ), ), title: "Filipino Cuisine", - home: Home()); + home: const Home()); } } class Home extends StatefulWidget { + const Home({Key? key}) : super(key: key); + @override HState createState() => HState(); } diff --git a/web/filipino_cuisine/lib/transformer_page_view.dart b/web/filipino_cuisine/lib/transformer_page_view.dart index e697ddbcb..c25e77273 100644 --- a/web/filipino_cuisine/lib/transformer_page_view.dart +++ b/web/filipino_cuisine/lib/transformer_page_view.dart @@ -141,7 +141,8 @@ class ParallaxColor extends StatefulWidget { required this.colors, required this.info, required this.child, - }); + Key? key, + }) : super(key: key); @override State createState() { @@ -159,7 +160,9 @@ class ParallaxContainer extends StatelessWidget { {required this.child, required this.position, this.translationFactor = 100.0, - this.opacityFactor = 1.0}); + this.opacityFactor = 1.0, + Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -178,13 +181,14 @@ class ParallaxImage extends StatelessWidget { final double imageFactor; ParallaxImage.asset(String name, - {required double position, this.imageFactor = 0.3}) + {required double position, this.imageFactor = 0.3, Key? key}) : image = Image.asset(name, fit: BoxFit.cover, alignment: FractionalOffset( 0.5 + position * imageFactor, 0.5, - )); + )), + super(key: key); @override Widget build(BuildContext context) { diff --git a/web/filipino_cuisine/pubspec.lock b/web/filipino_cuisine/pubspec.lock index 2d2fd37e3..9e296e47c 100644 --- a/web/filipino_cuisine/pubspec.lock +++ b/web/filipino_cuisine/pubspec.lock @@ -14,7 +14,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: diff --git a/web/samples_index/analysis_options.yaml b/web/samples_index/analysis_options.yaml index a0c881db6..d28c30e05 100644 --- a/web/samples_index/analysis_options.yaml +++ b/web/samples_index/analysis_options.yaml @@ -19,4 +19,3 @@ linter: test_types_in_equals: true throw_in_finally: true unnecessary_statements: true - use_key_in_widget_constructors: false