1
0
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:
Andrew Brogdon
2019-01-03 11:33:55 -08:00
committed by GitHub
parent 2128608386
commit 5d56599f7f
5 changed files with 512 additions and 10 deletions

View File

@@ -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],
),

View File

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