mirror of
https://github.com/flutter/samples.git
synced 2025-11-12 15:58:32 +00:00
Adds analysis options to Veggie Seasons (#98)
This commit is contained in:
@@ -32,19 +32,19 @@ class Preferences extends Model {
|
||||
return Set.from(_preferredCategories);
|
||||
}
|
||||
|
||||
void addPreferredCategory(VeggieCategory category) async {
|
||||
Future<void> addPreferredCategory(VeggieCategory category) async {
|
||||
_preferredCategories.add(category);
|
||||
await _saveToSharedPrefs();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void removePreferredCategory(VeggieCategory category) async {
|
||||
Future<void> removePreferredCategory(VeggieCategory category) async {
|
||||
_preferredCategories.remove(category);
|
||||
await _saveToSharedPrefs();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setDesiredCalories(int calories) async {
|
||||
Future<void> setDesiredCalories(int calories) async {
|
||||
_desiredCalories = calories;
|
||||
await _saveToSharedPrefs();
|
||||
notifyListeners();
|
||||
|
||||
@@ -23,7 +23,7 @@ class ServingInfoChart extends StatelessWidget {
|
||||
// value of this vitamin" data adjusted for the user's preferred calorie
|
||||
// target.
|
||||
Widget _buildVitaminText(int standardPercentage, Future<int> targetCalories) {
|
||||
return FutureBuilder(
|
||||
return FutureBuilder<int>(
|
||||
future: targetCalories,
|
||||
builder: (context, snapshot) {
|
||||
final target = snapshot?.data ?? 2000;
|
||||
@@ -172,7 +172,7 @@ class InfoView extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
FutureBuilder(
|
||||
FutureBuilder<Set<VeggieCategory>>(
|
||||
future: prefs.preferredCategories,
|
||||
builder: (context, snapshot) {
|
||||
return Text(
|
||||
@@ -284,7 +284,7 @@ class _DetailsScreenState extends State<DetailsScreen> {
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
CupertinoSegmentedControl(
|
||||
CupertinoSegmentedControl<int>(
|
||||
children: {
|
||||
0: Text('Facts & Info'),
|
||||
1: Text('Trivia'),
|
||||
|
||||
@@ -13,7 +13,8 @@ import 'package:veggieseasons/styles.dart';
|
||||
import 'package:veggieseasons/widgets/veggie_card.dart';
|
||||
|
||||
class ListScreen extends StatelessWidget {
|
||||
Widget _generateVeggieRow(veggie, Preferences prefs, {bool inSeason = true}) {
|
||||
Widget _generateVeggieRow(Veggie veggie, Preferences prefs,
|
||||
{bool inSeason = true}) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(left: 16, right: 16, bottom: 24),
|
||||
child: FutureBuilder<Set<VeggieCategory>>(
|
||||
|
||||
@@ -126,7 +126,7 @@ class CalorieSettingsScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
class SettingsScreen extends StatelessWidget {
|
||||
Widget _buildCaloriesItem(BuildContext context, Preferences prefs) {
|
||||
SettingsItem _buildCaloriesItem(BuildContext context, Preferences prefs) {
|
||||
return SettingsItem(
|
||||
label: 'Calorie Target',
|
||||
icon: SettingsIcon(
|
||||
@@ -146,7 +146,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
onPress: () {
|
||||
Navigator.of(context).push(
|
||||
Navigator.of(context).push<void>(
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => CalorieSettingsScreen(),
|
||||
title: 'Calorie Target',
|
||||
@@ -156,7 +156,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCategoriesItem(BuildContext context, Preferences prefs) {
|
||||
SettingsItem _buildCategoriesItem(BuildContext context, Preferences prefs) {
|
||||
return SettingsItem(
|
||||
label: 'Preferred Categories',
|
||||
subtitle: 'What types of veggies you prefer!',
|
||||
@@ -166,7 +166,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
),
|
||||
content: SettingsNavigationIndicator(),
|
||||
onPress: () {
|
||||
Navigator.of(context).push(
|
||||
Navigator.of(context).push<void>(
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => VeggieCategorySettingsScreen(),
|
||||
title: 'Preferred Categories',
|
||||
|
||||
@@ -69,12 +69,12 @@ class _ColorChangingIconState
|
||||
}
|
||||
|
||||
@override
|
||||
void forEachTween(visitor) {
|
||||
void forEachTween(TweenVisitor<dynamic> visitor) {
|
||||
_colorTween = visitor(
|
||||
_colorTween,
|
||||
widget.color,
|
||||
(dynamic value) => ColorTween(begin: value),
|
||||
);
|
||||
(dynamic value) => ColorTween(begin: value as Color),
|
||||
) as ColorTween;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class SettingsGroup extends StatelessWidget {
|
||||
this.header,
|
||||
this.footer,
|
||||
}) : assert(items != null),
|
||||
assert(items.length > 0);
|
||||
assert(items.isNotEmpty);
|
||||
|
||||
final List<SettingsItem> items;
|
||||
final Widget header;
|
||||
|
||||
@@ -143,7 +143,7 @@ class VeggieCard extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return PressableCard(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
Navigator.of(context).push<void>(CupertinoPageRoute(
|
||||
builder: (context) => DetailsScreen(veggie.id),
|
||||
fullscreenDialog: true,
|
||||
));
|
||||
|
||||
@@ -68,7 +68,7 @@ class VeggieHeadline extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => Navigator.of(context).push(CupertinoPageRoute(
|
||||
onTap: () => Navigator.of(context).push<void>(CupertinoPageRoute(
|
||||
builder: (context) => DetailsScreen(veggie.id),
|
||||
fullscreenDialog: true,
|
||||
)),
|
||||
|
||||
Reference in New Issue
Block a user