I have data from Firebase that looks something like this:
{
"foo": {
1: true,
2: false
},
"bar": {
3: true,
4: false
}
}
If I'm not mistaken, this should be a Map<String, Map<int, bool>>
. I'm trying to use this function to safely cast it:
T castWithDefaultValue<T> (val, T defaultValue) => val is T ? val : defaultValue;
var castData = castWithDefaultValue<Map<String, Map<int, bool>>>(dataFromFirebase, {});
But it fails, always returning the default value. The only types I can get to work for either the key or the value are Object?
and dynamic
, but I want more type safety. How do I get it to what I want it to be?