1
0
mirror of https://github.com/flutter/samples.git synced 2026-05-10 17:07:28 +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

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