mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
Upgrading samples to flutter_lints, part 1 of n (#804)
This commit is contained in:
@@ -43,7 +43,7 @@ class ServingInfoChart extends StatelessWidget {
|
||||
final themeData = CupertinoTheme.of(context);
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(height: 16),
|
||||
const SizedBox(height: 16),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
@@ -187,9 +187,9 @@ class InfoView extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
Spacer(),
|
||||
const Spacer(),
|
||||
for (Season season in veggie.seasons) ...[
|
||||
SizedBox(width: 12),
|
||||
const SizedBox(width: 12),
|
||||
Padding(
|
||||
padding: Styles.seasonIconPadding[season],
|
||||
child: Icon(
|
||||
@@ -201,18 +201,18 @@ class InfoView extends StatelessWidget {
|
||||
],
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
veggie.name,
|
||||
style: Styles.detailsTitleText(themeData),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
veggie.shortDescription,
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
),
|
||||
ServingInfoChart(veggie, prefs),
|
||||
SizedBox(height: 24),
|
||||
const SizedBox(height: 24),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -222,7 +222,7 @@ class InfoView extends StatelessWidget {
|
||||
appState.setFavorite(id, value);
|
||||
},
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Save to Garden',
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
@@ -239,7 +239,7 @@ class DetailsScreen extends StatefulWidget {
|
||||
final int id;
|
||||
final String restorationId;
|
||||
|
||||
DetailsScreen({this.id, this.restorationId});
|
||||
const DetailsScreen({this.id, this.restorationId});
|
||||
|
||||
static String show(NavigatorState navigator, int veggieId) {
|
||||
return navigator.restorablePush<void>(_routeBuilder, arguments: veggieId);
|
||||
@@ -321,9 +321,9 @@ class _DetailsScreenState extends State<DetailsScreen> with RestorationMixin {
|
||||
restorationId: 'list',
|
||||
children: [
|
||||
_buildHeader(context, appState),
|
||||
SizedBox(height: 20),
|
||||
const SizedBox(height: 20),
|
||||
CupertinoSegmentedControl<int>(
|
||||
children: {
|
||||
children: const {
|
||||
0: Text(
|
||||
'Facts & Info',
|
||||
),
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:veggieseasons/data/veggie.dart';
|
||||
import 'package:veggieseasons/widgets/veggie_headline.dart';
|
||||
|
||||
class FavoritesScreen extends StatelessWidget {
|
||||
FavoritesScreen({this.restorationId, Key key}) : super(key: key);
|
||||
const FavoritesScreen({this.restorationId, Key key}) : super(key: key);
|
||||
|
||||
final String restorationId;
|
||||
|
||||
@@ -22,7 +22,7 @@ class FavoritesScreen extends StatelessWidget {
|
||||
final model = Provider.of<AppState>(context);
|
||||
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
navigationBar: const CupertinoNavigationBar(
|
||||
middle: Text('My Garden'),
|
||||
),
|
||||
child: Center(
|
||||
@@ -37,10 +37,10 @@ class FavoritesScreen extends StatelessWidget {
|
||||
: ListView(
|
||||
restorationId: 'list',
|
||||
children: [
|
||||
SizedBox(height: 24),
|
||||
const SizedBox(height: 24),
|
||||
for (Veggie veggie in model.favoriteVeggies)
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(16, 0, 16, 24),
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 24),
|
||||
child: VeggieHeadline(veggie),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:veggieseasons/screens/search.dart';
|
||||
import 'package:veggieseasons/screens/settings.dart';
|
||||
|
||||
class HomeScreen extends StatelessWidget {
|
||||
HomeScreen({Key key, this.restorationId}) : super(key: key);
|
||||
const HomeScreen({Key key, this.restorationId}) : super(key: key);
|
||||
|
||||
final String restorationId;
|
||||
|
||||
@@ -20,7 +20,7 @@ class HomeScreen extends StatelessWidget {
|
||||
restorationId: restorationId,
|
||||
child: CupertinoTabScaffold(
|
||||
restorationId: 'scaffold',
|
||||
tabBar: CupertinoTabBar(items: [
|
||||
tabBar: CupertinoTabBar(items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.home),
|
||||
label: 'Home',
|
||||
@@ -40,13 +40,13 @@ class HomeScreen extends StatelessWidget {
|
||||
]),
|
||||
tabBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return ListScreen(restorationId: 'list');
|
||||
return const ListScreen(restorationId: 'list');
|
||||
} else if (index == 1) {
|
||||
return FavoritesScreen(restorationId: 'favorites');
|
||||
return const FavoritesScreen(restorationId: 'favorites');
|
||||
} else if (index == 2) {
|
||||
return SearchScreen(restorationId: 'search');
|
||||
return const SearchScreen(restorationId: 'search');
|
||||
} else {
|
||||
return SettingsScreen(restorationId: 'settings');
|
||||
return const SettingsScreen(restorationId: 'settings');
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
@@ -14,14 +14,14 @@ import 'package:veggieseasons/styles.dart';
|
||||
import 'package:veggieseasons/widgets/veggie_card.dart';
|
||||
|
||||
class ListScreen extends StatelessWidget {
|
||||
ListScreen({this.restorationId, Key key}) : super(key: key);
|
||||
const ListScreen({this.restorationId, Key key}) : super(key: key);
|
||||
|
||||
final String restorationId;
|
||||
|
||||
Widget _generateVeggieRow(Veggie veggie, Preferences prefs,
|
||||
{bool inSeason = true}) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(left: 16, right: 16, bottom: 24),
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 24),
|
||||
child: FutureBuilder<Set<VeggieCategory>>(
|
||||
future: prefs.preferredCategories,
|
||||
builder: (context, snapshot) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:veggieseasons/data/veggie.dart';
|
||||
import 'package:veggieseasons/widgets/veggie_headline.dart';
|
||||
|
||||
class SearchScreen extends StatefulWidget {
|
||||
SearchScreen({this.restorationId, Key key}) : super(key: key);
|
||||
const SearchScreen({this.restorationId, Key key}) : super(key: key);
|
||||
|
||||
final String restorationId;
|
||||
|
||||
@@ -85,7 +85,7 @@ class _SearchScreenState extends State<SearchScreen> with RestorationMixin {
|
||||
);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(left: 16, right: 16, bottom: 24),
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 24),
|
||||
child: VeggieHeadline(veggies[i - 1]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ import 'package:veggieseasons/widgets/settings_group.dart';
|
||||
import 'package:veggieseasons/widgets/settings_item.dart';
|
||||
|
||||
class VeggieCategorySettingsScreen extends StatelessWidget {
|
||||
VeggieCategorySettingsScreen({Key key, this.restorationId}) : super(key: key);
|
||||
const VeggieCategorySettingsScreen({Key key, this.restorationId})
|
||||
: super(key: key);
|
||||
|
||||
final String restorationId;
|
||||
|
||||
@@ -24,7 +25,7 @@ class VeggieCategorySettingsScreen extends StatelessWidget {
|
||||
static Route<void> _routeBuilder(BuildContext context, Object argument) {
|
||||
return CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
VeggieCategorySettingsScreen(restorationId: 'category'),
|
||||
const VeggieCategorySettingsScreen(restorationId: 'category'),
|
||||
title: 'Preferred Categories',
|
||||
);
|
||||
}
|
||||
@@ -37,7 +38,7 @@ class VeggieCategorySettingsScreen extends StatelessWidget {
|
||||
return RestorationScope(
|
||||
restorationId: restorationId,
|
||||
child: CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
navigationBar: const CupertinoNavigationBar(
|
||||
middle: Text('Preferred Categories'),
|
||||
previousPageTitle: 'Settings',
|
||||
),
|
||||
@@ -65,7 +66,7 @@ class VeggieCategorySettingsScreen extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
} else {
|
||||
toggle = CupertinoSwitch(
|
||||
toggle = const CupertinoSwitch(
|
||||
value: false,
|
||||
onChanged: null,
|
||||
);
|
||||
@@ -93,7 +94,7 @@ class VeggieCategorySettingsScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
class CalorieSettingsScreen extends StatelessWidget {
|
||||
CalorieSettingsScreen({Key key, this.restorationId}) : super(key: key);
|
||||
const CalorieSettingsScreen({Key key, this.restorationId}) : super(key: key);
|
||||
|
||||
final String restorationId;
|
||||
|
||||
@@ -107,7 +108,8 @@ class CalorieSettingsScreen extends StatelessWidget {
|
||||
|
||||
static Route<void> _routeBuilder(BuildContext context, Object argument) {
|
||||
return CupertinoPageRoute<void>(
|
||||
builder: (context) => CalorieSettingsScreen(restorationId: 'calorie'),
|
||||
builder: (context) =>
|
||||
const CalorieSettingsScreen(restorationId: 'calorie'),
|
||||
title: 'Calorie Target',
|
||||
);
|
||||
}
|
||||
@@ -119,7 +121,7 @@ class CalorieSettingsScreen extends StatelessWidget {
|
||||
return RestorationScope(
|
||||
restorationId: restorationId,
|
||||
child: CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
navigationBar: const CupertinoNavigationBar(
|
||||
previousPageTitle: 'Settings',
|
||||
),
|
||||
backgroundColor: Styles.scaffoldBackground(brightness),
|
||||
@@ -152,9 +154,10 @@ class CalorieSettingsScreen extends StatelessWidget {
|
||||
|
||||
return SettingsGroup(
|
||||
items: steps,
|
||||
header: SettingsGroupHeader('Available calorie levels'),
|
||||
footer: SettingsGroupFooter('These are used for serving '
|
||||
'calculations'),
|
||||
header: const SettingsGroupHeader('Available calorie levels'),
|
||||
footer:
|
||||
const SettingsGroupFooter('These are used for serving '
|
||||
'calculations'),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -166,14 +169,14 @@ class CalorieSettingsScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
class SettingsScreen extends StatelessWidget {
|
||||
SettingsScreen({this.restorationId, Key key}) : super(key: key);
|
||||
const SettingsScreen({this.restorationId, Key key}) : super(key: key);
|
||||
|
||||
final String restorationId;
|
||||
|
||||
SettingsItem _buildCaloriesItem(BuildContext context, Preferences prefs) {
|
||||
return SettingsItem(
|
||||
label: 'Calorie Target',
|
||||
icon: SettingsIcon(
|
||||
icon: const SettingsIcon(
|
||||
backgroundColor: Styles.iconBlue,
|
||||
icon: Styles.calorieIcon,
|
||||
),
|
||||
@@ -186,8 +189,8 @@ class SettingsScreen extends StatelessWidget {
|
||||
snapshot.data?.toString() ?? '',
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
SettingsNavigationIndicator(),
|
||||
const SizedBox(width: 8),
|
||||
const SettingsNavigationIndicator(),
|
||||
],
|
||||
);
|
||||
},
|
||||
@@ -202,11 +205,11 @@ class SettingsScreen extends StatelessWidget {
|
||||
return SettingsItem(
|
||||
label: 'Preferred Categories',
|
||||
subtitle: 'What types of veggies you prefer!',
|
||||
icon: SettingsIcon(
|
||||
icon: const SettingsIcon(
|
||||
backgroundColor: Styles.iconGold,
|
||||
icon: Styles.preferenceIcon,
|
||||
),
|
||||
content: SettingsNavigationIndicator(),
|
||||
content: const SettingsNavigationIndicator(),
|
||||
onPress: () {
|
||||
VeggieCategorySettingsScreen.show(Navigator.of(context));
|
||||
},
|
||||
@@ -217,23 +220,23 @@ class SettingsScreen extends StatelessWidget {
|
||||
BuildContext context, Preferences prefs) {
|
||||
return SettingsItem(
|
||||
label: 'Restore Defaults',
|
||||
icon: SettingsIcon(
|
||||
icon: const SettingsIcon(
|
||||
backgroundColor: CupertinoColors.systemRed,
|
||||
icon: Styles.resetIcon,
|
||||
),
|
||||
content: SettingsNavigationIndicator(),
|
||||
content: const SettingsNavigationIndicator(),
|
||||
onPress: () {
|
||||
showCupertinoDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoAlertDialog(
|
||||
title: Text('Are you sure?'),
|
||||
content: Text(
|
||||
title: const Text('Are you sure?'),
|
||||
content: const Text(
|
||||
'Are you sure you want to reset the current settings?',
|
||||
),
|
||||
actions: <Widget>[
|
||||
CupertinoDialogAction(
|
||||
isDestructiveAction: true,
|
||||
child: Text('Yes'),
|
||||
child: const Text('Yes'),
|
||||
onPressed: () async {
|
||||
await prefs.restoreDefaults();
|
||||
Navigator.pop(context);
|
||||
@@ -241,7 +244,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDefaultAction: true,
|
||||
child: Text('No'),
|
||||
child: const Text('No'),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
)
|
||||
],
|
||||
@@ -264,7 +267,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
child: CustomScrollView(
|
||||
restorationId: 'list',
|
||||
slivers: <Widget>[
|
||||
CupertinoSliverNavigationBar(
|
||||
const CupertinoSliverNavigationBar(
|
||||
largeTitle: Text('Settings'),
|
||||
),
|
||||
SliverSafeArea(
|
||||
|
||||
Reference in New Issue
Block a user