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
pull/925/head
Brett Morgan 3 years ago committed by GitHub
parent e160f5261c
commit e2e2713986
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 {

@ -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.');

@ -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

@ -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

@ -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

@ -17,4 +17,3 @@ linter:
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
use_key_in_widget_constructors: false

@ -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();

@ -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<AppState>(context);
@ -41,7 +43,7 @@ class DashboardPage extends StatelessWidget {
class Dashboard extends StatelessWidget {
final List<Category> categories;
const Dashboard(this.categories);
const Dashboard(this.categories, {Key key}) : super(key: key);
@override
Widget build(BuildContext context) {

@ -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) {

@ -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<HomePage> {
if (_pageIndex == 0) {
showDialog<NewCategoryDialog>(
context: context,
builder: (context) => NewCategoryDialog(),
builder: (context) => const NewCategoryDialog(),
);
return;
}
@ -78,7 +79,7 @@ class _HomePageState extends State<HomePage> {
if (_pageIndex == 1) {
showDialog<NewEntryDialog>(
context: context,
builder: (context) => NewEntryDialog(),
builder: (context) => const NewEntryDialog(),
);
return;
}
@ -115,11 +116,11 @@ class _HomePageState extends State<HomePage> {
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'));

@ -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();

@ -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();

@ -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) {

@ -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();

@ -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: <Widget>[
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<NewEntryDialog> {
@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) {

@ -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();

@ -43,7 +43,8 @@ class AdaptiveScaffold extends StatefulWidget {
@required this.destinations,
this.onNavigationIndexChange,
this.floatingActionButton,
});
Key key,
}) : super(key: key);
@override
_AdaptiveScaffoldState createState() => _AdaptiveScaffoldState();

@ -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

@ -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<DemoInfo> 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) {

@ -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();
}

@ -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;

@ -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();
}

@ -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<PetListScreen> {
class BuildPetList extends StatelessWidget {
final List<PetDetails> petList;
const BuildPetList(this.petList);
const BuildPetList(this.petList, {Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {

@ -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();
}

@ -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(),
));

@ -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');

@ -49,7 +49,7 @@ void main() {
testWidgets('EventChannel AccelerometerReadings Stream test',
(tester) async {
await tester.pumpWidget(MaterialApp(
await tester.pumpWidget(const MaterialApp(
home: EventChannelDemo(),
));

@ -26,7 +26,7 @@ void main() {
});
testWidgets('MethodChannelDemo count test', (tester) async {
await tester.pumpWidget(MaterialApp(
await tester.pumpWidget(const MaterialApp(
home: MethodChannelDemo(),
));

@ -20,7 +20,7 @@ void main() {
});
testWidgets('Platform Image test', (tester) async {
await tester.pumpWidget(MaterialApp(
await tester.pumpWidget(const MaterialApp(
home: PlatformImageDemo(),
));

@ -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

@ -17,4 +17,3 @@ linter:
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
use_key_in_widget_constructors: false

@ -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(

@ -17,4 +17,3 @@ linter:
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
use_key_in_widget_constructors: false

@ -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(

@ -13,7 +13,7 @@ void main() {
await tester.pumpWidget(
ChangeNotifierProvider(
create: (context) => Counter(),
child: MyApp(),
child: const MyApp(),
),
);

@ -17,4 +17,3 @@ linter:
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
use_key_in_widget_constructors: false

@ -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(),
},
),
);

@ -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(

@ -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(

@ -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(

@ -24,7 +24,7 @@ Widget createCartScreen() => MultiProvider(
},
),
],
child: MaterialApp(
child: const MaterialApp(
home: MyCart(),
),
);

@ -21,7 +21,7 @@ Widget createCatalogScreen() => MultiProvider(
},
),
],
child: MaterialApp(
child: const MaterialApp(
home: MyCatalog(),
),
);

@ -26,8 +26,8 @@ void main() {
child: MaterialApp(
initialRoute: '/',
routes: {
'/': (context) => MyLogin(),
'/catalog': (context) => MyCatalog(),
'/': (context) => const MyLogin(),
'/catalog': (context) => const MyCatalog(),
},
),
));

@ -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'));

@ -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

@ -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')));

@ -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.

@ -16,7 +16,7 @@ Widget createFavoritesScreen() => ChangeNotifierProvider<Favorites>(
favoritesList = Favorites();
return favoritesList;
},
child: MaterialApp(
child: const MaterialApp(
home: FavoritesPage(),
),
);

@ -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<Favorites>(
@ -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,
),

@ -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) {

@ -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) {

@ -15,7 +15,7 @@ Widget createFavoritesScreen() => ChangeNotifierProvider<Favorites>(
favoritesList = Favorites();
return favoritesList;
},
child: MaterialApp(
child: const MaterialApp(
home: FavoritesPage(),
),
);

@ -10,7 +10,7 @@ import 'package:testing_app/screens/home.dart';
Widget createHomeScreen() => ChangeNotifierProvider<Favorites>(
create: (context) => Favorites(),
child: MaterialApp(
child: const MaterialApp(
home: HomePage(),
),
);

@ -17,4 +17,3 @@ linter:
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
use_key_in_widget_constructors: false

@ -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<StatefulWidget> createState() => _VeggieAppState();
}

@ -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<void>(_routeBuilder, arguments: veggieId);

@ -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;

@ -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<SettingsItem> items;
final Widget header;

@ -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();

@ -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<PressableCard> {
}
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;

@ -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<Widget> _buildSeasonDots(List<Season> seasons) {
var widgets = <Widget>[];

@ -16,7 +16,7 @@ void main() {
AppState.debugCurrentSeason = Season.autumn;
await tester.pumpWidget(
RootRestorationScope(
const RootRestorationScope(
restorationId: 'root',
child: VeggieApp(),
),

@ -17,4 +17,3 @@ linter:
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
use_key_in_widget_constructors: false

@ -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();
}

@ -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) {

@ -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();
}

@ -141,7 +141,8 @@ class ParallaxColor extends StatefulWidget {
required this.colors,
required this.info,
required this.child,
});
Key? key,
}) : super(key: key);
@override
State<StatefulWidget> 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) {

@ -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:

@ -19,4 +19,3 @@ linter:
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
use_key_in_widget_constructors: false

Loading…
Cancel
Save