mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
Fleshes out settings screen with groups, items, and navigation (#43)
This commit is contained in:
@@ -228,7 +228,7 @@ class LocalVeggieProvider {
|
||||
name: 'Squash',
|
||||
imageAssetPath: 'assets/images/squash.jpg',
|
||||
category: VeggieCategory.gourd,
|
||||
shortDescription: 'Bigger and heartier than summer squashes.',
|
||||
shortDescription: 'Just slather them in butter and pop \'em in the oven.',
|
||||
accentColor: Color(0x40dbb721),
|
||||
seasons: [Season.winter, Season.autumn],
|
||||
),
|
||||
|
||||
@@ -68,12 +68,14 @@ class Preferences extends Model {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_desiredCalories = prefs.getInt(_caloriesKey) ?? 2000;
|
||||
_preferredCategories.clear();
|
||||
final names = prefs.getString(_preferredCategoriesKey) ?? '';
|
||||
final names = prefs.getString(_preferredCategoriesKey);
|
||||
|
||||
for (final name in names.split(',')) {
|
||||
final index = int.parse(name) ?? 0;
|
||||
if (VeggieCategory.values[index] != null) {
|
||||
_preferredCategories.add(VeggieCategory.values[index]);
|
||||
if (names != null) {
|
||||
for (final name in names.split(',')) {
|
||||
final index = int.tryParse(name) ?? -1;
|
||||
if (VeggieCategory.values[index] != null) {
|
||||
_preferredCategories.add(VeggieCategory.values[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user