1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 14:58:34 +00:00

Samples maintenance (#435)

This commit is contained in:
Brett Morgan
2020-05-13 09:18:26 +10:00
committed by GitHub
parent 941ebebfad
commit baa1f976b2
94 changed files with 492 additions and 349 deletions

View File

@@ -7,7 +7,7 @@ import 'package:veggieseasons/data/veggie.dart';
import 'package:veggieseasons/data/local_veggie_provider.dart';
class AppState extends Model {
List<Veggie> _veggies;
final List<Veggie> _veggies;
AppState() : _veggies = LocalVeggieProvider.veggies;
@@ -16,12 +16,12 @@ class AppState extends Model {
Veggie getVeggie(int id) => _veggies.singleWhere((v) => v.id == id);
List<Veggie> get availableVeggies {
Season currentSeason = _getSeasonForDate(DateTime.now());
var currentSeason = _getSeasonForDate(DateTime.now());
return _veggies.where((v) => v.seasons.contains(currentSeason)).toList();
}
List<Veggie> get unavailableVeggies {
Season currentSeason = _getSeasonForDate(DateTime.now());
var currentSeason = _getSeasonForDate(DateTime.now());
return _veggies.where((v) => !v.seasons.contains(currentSeason)).toList();
}
@@ -33,7 +33,7 @@ class AppState extends Model {
.toList();
void setFavorite(int id, bool isFavorite) {
Veggie veggie = getVeggie(id);
var veggie = getVeggie(id);
veggie.isFavorite = isFavorite;
notifyListeners();
}

View File

@@ -20,7 +20,7 @@ class Preferences extends Model {
int _desiredCalories = 2000;
Set<VeggieCategory> _preferredCategories = Set<VeggieCategory>();
final Set<VeggieCategory> _preferredCategories = <VeggieCategory>{};
Future<int> get desiredCalories async {
await _loading;