@@ -12,12 +12,11 @@ import 'service/query_service.dart';
1212class RecipeBookController {
1313
1414 static const String LOADING_MESSAGE = "Loading recipe book..." ;
15- static const String ERROR_MESSAGE = """ Sorry! The cook stepped out of the
16- kitchen and took the recipe book with him!"" " ;
15+ static const String ERROR_MESSAGE = "Sorry! The cook stepped out of the"
16+ " kitchen and took the recipe book with him!" ;
1717
18- Http _http;
19- QueryService _queryService;
20- QueryService get queryService => _queryService;
18+ final Http _http;
19+ final QueryService queryService;
2120
2221 // Determine the initial load state of the app
2322 String message = LOADING_MESSAGE ;
@@ -27,15 +26,18 @@ kitchen and took the recipe book with him!""";
2726 // Data objects that are loaded from the server side via json
2827 List <String > _categories = [];
2928 List <String > get categories => _categories;
29+
3030 Map <String , Recipe > _recipeMap = {};
3131 Map <String , Recipe > get recipeMap => _recipeMap;
32- List <Recipe > get allRecipes => _recipeMap.values.toList ();
32+ List <Recipe > _allRecipes = [];
33+
34+ List <Recipe > get allRecipes => _allRecipes;
3335
3436 // Filter box
35- Map <String , bool > categoryFilterMap = {};
37+ final categoryFilterMap = < String , bool > {};
3638 String nameFilter = "" ;
3739
38- RecipeBookController (Http this ._http, QueryService this ._queryService ) {
40+ RecipeBookController (this ._http, this .queryService ) {
3941 _loadData ();
4042 }
4143
@@ -58,9 +60,10 @@ kitchen and took the recipe book with him!""";
5860 }
5961
6062 void _loadData () {
61- _queryService .getAllRecipes ()
63+ queryService .getAllRecipes ()
6264 .then ((Map <String , Recipe > allRecipes) {
6365 _recipeMap = allRecipes;
66+ _allRecipes = _recipeMap.values.toList ();
6467 recipesLoaded = true ;
6568 })
6669 .catchError ((e) {
@@ -69,7 +72,7 @@ kitchen and took the recipe book with him!""";
6972 message = ERROR_MESSAGE ;
7073 });
7174
72- _queryService .getAllCategories ()
75+ queryService .getAllCategories ()
7376 .then ((List <String > allCategories) {
7477 _categories = allCategories;
7578 for (String category in _categories) {
@@ -83,4 +86,4 @@ kitchen and took the recipe book with him!""";
8386 message = ERROR_MESSAGE ;
8487 });
8588 }
86- }
89+ }
0 commit comments