Dictionary constructor
Dictionary([
- Mapping? dict
Type Erasure
Implementation
Dictionary([Mapping? dict])
: _map = dict == null ? <String, dynamic>{}.asMutableMapping()
: dict is Mapper ? dict.toMap()
: dict.asMutableMapping() {
// Ensure that all keys are of type String.
assert(() {
try {
// check type
final _ = _map as MutableMapping<String, dynamic>;
} catch (_) {
// type error
return false;
}
if (dict != null) {
// check all keys
for (final key in dict.keys) {
if (key is! String) {
// key error
return false;
}
}
}
// OK
return true;
}(), '⚠️ Debug hint: underlying map debug type‑argument is NOT Map<String,dynamic>. '
'It may be Map<dynamic,dynamic>.\n'
'Ensure all keys are String. map=$dict');
}