Best practice to cast a dynamic object? Sure wish people would answer with an Answer (rather than a comment), so that it can be accepted and all that SO goodness. First, lets redefine the toppings field: Then, in our fromJson method we will have to do the following: Notice, how we have a temporary variable to first extract the value from the json variable and then we explicitly convert the value to our toppings list original type. Why does my stock Samsung Galaxy phone/tablet lack some features compared to other Samsung Galaxy models? A value of type Object can't be assigned to a variable of type FoodScreenArguments. We have 3 steps to convert an Object/List to JSON string: create the class. And now we can serialize it by using jsonEncode: Under the hood, jsonEncode calls our own toJson method that we created in our doughnut model class. Unlike java's parentheses casting (), in flutter, it uses as keyword. Flutter Objectdynamic const final flutter Flutter Objectdynamic 2 Dynamic signifies an unknown type in the dart language, one which will be realized during runtime. My question is whether this is the 'most correct' way to work with the dynamic object returned by http GET? How do I arrange multiple quotations (each with multiple lines) vertically (with a line through the center) so that they're side-by-side? You cannot re-assign the variable as an integer. While developing a Flutter application (or any application using Dart language), you may face a situation where you get the data of an object in the form of JSON string and you need to convert it to a Dart object. Can virent/viret mean "green" in an adjectival sense? Would it be possible, given current technology, ten years, and an infinite amount of money, to construct a 7,000 foot (2200 meter) aircraft carrier? Each doughnut is an object that contains the following keys: You may have noticed a weird type in there called dynamic. dynamic | Flutter by Example dynamic on Saturday, 18th of July, 2020 Inferring the type Dart is a typed language. I've recently added the lint dev package https://pub.dev/packages/lint to standardize my projects' code style and follow better practices, however I'm having an issue trying to follow one of the lint suggestions: The code below retrieves json data using http GET which returns a dynamic data type and then tries to parse the known data structure into a proper type, specifically List