breaking exception '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, String>'
The constructor for Uri.https
requires a Map with a runtime type of Map<String, String>
. When you create stringParams
without any type annotations, you are actually creating a Map<dynamic, dynamic>
. The correct way to create this for Dart 2 is
Map<String, String> stringParams = {};
// or
var stringParams = <String, String>{};
The reason this used to work is that in Dart 1, even in strong mode, dynamic
was fuzzy and acted like both Object
and null
- meaning a dynamic type was assignable to and from anything. In Dart 2, dynamic
acts just like Object
, except you can call methods or access properties on it without a downcast.
I used this
if(json["key"]!= null){
this.active_guests = json["key"].cast<String, int>();
}