Skip to content

Commit 1c60ace

Browse files
committed
Merge pull request dart-archive#99 from chalin/patch-0312-recipe-json-ctr-rename
refactor(Recipe): rename constructor fromJsonMap to fromJson
2 parents fb7e266 + 73bb8b2 commit 1c60ace

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

Chapter_05/lib/recipe.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Recipe {
2222
"imgUrl": imgUrl
2323
};
2424

25-
factory Recipe.fromJsonMap(Map<String, dynamic> json) => new Recipe(json['id'],
25+
factory Recipe.fromJson(Map<String, dynamic> json) => new Recipe(json['id'],
2626
json['name'], json['category'], json['ingredients'], json['directions'],
2727
json['rating'], json['imgUrl']);
2828
}

Chapter_05/lib/recipe_book.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ kitchen and took the recipe book with him!""";
6363
.then((HttpResponse response) {
6464
print(response);
6565
for (Map recipe in response.data) {
66-
recipes.add(new Recipe.fromJsonMap(recipe));
66+
recipes.add(new Recipe.fromJson(recipe));
6767
}
6868
recipesLoaded = true;
6969
})

Chapter_06/lib/service/query_service.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class QueryService {
2323
Future _loadRecipes() {
2424
return _http.get(_recipesUrl)
2525
.then((HttpResponse response) {
26-
_recipesCache = new Map();
26+
_recipesCache = new Map<String, Recipe>();
2727
for (Map recipe in response.data) {
28-
Recipe r = new Recipe.fromJsonMap(recipe);
28+
Recipe r = new Recipe.fromJson(recipe);
2929
_recipesCache[r.id] = r;
3030
}
3131
});
@@ -34,7 +34,7 @@ class QueryService {
3434
Future _loadCategories() {
3535
return _http.get(_categoriesUrl)
3636
.then((HttpResponse response) {
37-
_categoriesCache = new List();
37+
_categoriesCache = new List<String>();
3838
for (String category in response.data) {
3939
_categoriesCache.add(category);
4040
}

Chapter_06/lib/service/recipe.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Recipe {
2222
"imgUrl": imgUrl
2323
};
2424

25-
factory Recipe.fromJsonMap(Map<String, dynamic> json) => new Recipe(json['id'],
25+
factory Recipe.fromJson(Map<String, dynamic> json) => new Recipe(json['id'],
2626
json['name'], json['category'], json['ingredients'], json['directions'],
2727
json['rating'], json['imgUrl']);
2828
}

Chapter_07/lib/service/query_service.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class QueryService {
2323
Future _loadRecipes() {
2424
return _http.get(_recipesUrl)
2525
.then((HttpResponse response) {
26-
_recipesCache = new Map();
26+
_recipesCache = new Map<String, Recipe>();
2727
for (Map recipe in response.data) {
28-
Recipe r = new Recipe.fromJsonMap(recipe);
28+
Recipe r = new Recipe.fromJson(recipe);
2929
_recipesCache[r.id] = r;
3030
}
3131
});
@@ -34,7 +34,7 @@ class QueryService {
3434
Future _loadCategories() {
3535
return _http.get(_categoriesUrl)
3636
.then((HttpResponse response) {
37-
_categoriesCache = new List();
37+
_categoriesCache = new List<String>();
3838
for (String category in response.data) {
3939
_categoriesCache.add(category);
4040
}

Chapter_07/lib/service/recipe.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Recipe {
2222
"imgUrl": imgUrl
2323
};
2424

25-
factory Recipe.fromJsonMap(Map<String, dynamic> json) => new Recipe(json['id'],
25+
factory Recipe.fromJson(Map<String, dynamic> json) => new Recipe(json['id'],
2626
json['name'], json['category'], json['ingredients'], json['directions'],
2727
json['rating'], json['imgUrl']);
2828
}

0 commit comments

Comments
 (0)