Hi,
I could not get the app to run on iOS simulator (iOS18.2 on iPhone 16) unless updating dependencies. It was a hard NO from compiler.
After this however, various things don’t work. The details page doesn’t load anything with log: flutter: [MESSAGE] Problems getting Recipe null
Bookmarks don’t work even in the supplied code for end of chapter 13.
Any fixes to the book coming?
I am using Flutter 3.16. The starter project for chpt 13 does not load any recipe details and gives this same error. Same accross platforms. I can see from the Spoonacular http response there is a summary section which is what should be loaded to the details page.
Hi, i was able to fix it after some troubleshooting by myself. The issue is not really your dependency version, it’s about the json serializable for some nullable fields.
in the spoonacular_model.dart file, change the SpoonacularRecipe definition
@JsonSerializable()
class SpoonacularRecipe {
int? preparationMinutes;
int? cookingMinutes;
String sourceName;
List<ExtendedIngredient> extendedIngredients;
int id;
String title;
int? readyInMinutes;
int servings;
String sourceUrl;
String image;
String imageType;
String summary;
String? instructions;
SpoonacularRecipe({
this.preparationMinutes,
this.cookingMinutes,
required this.sourceName,
required this.extendedIngredients,
required this.id,
required this.title,
this.readyInMinutes,
required this.servings,
required this.sourceUrl,
required this.image,
required this.imageType,
required this.summary,
this.instructions,
});
factory SpoonacularRecipe.fromJson(Map<String, dynamic> json) =>
_$SpoonacularRecipeFromJson(json);
Map<String, dynamic> toJson() => _$SpoonacularRecipeToJson(this);
}
These integer fields are nullable, so caused problem in JsonSerializable.
ps: remember to run the dart run build_runner build again, after the change.
I suggest the staff made these changes in the repo for edition 4.0 as well ( i don’t have the branch or pull request permission by myself )
Thanks a ton for that - I’d noticed the null error in the logs but… had assumed this was ok somehow seeing as it’s in the book!.. lesson learned!!