I have this small code snippet:
class A<T> {
  A(this.a);
  
  final T a;
}
void main() {
  final a = A(true);
  print(a);
  print(a as A<bool>);
  
  final b = A<Object>(true);
  print(b);
  print(b as A<bool>);  
}
I'm receiving the object b from a library/API which is a A<Object> (and I don't have control over it), but I know it is actually a A<bool> in my specific case. I'm trying to cast it to A<bool> (as in my code snippet with b). But I get an error saying that A<Object> is not a subtype of A<bool>.
Here are the logs from the code snippet pasted above:
Instance of 'A<bool>'
Instance of 'A<bool>'
Instance of 'A<Object>'
Uncaught Error: TypeError: Instance of 'A<Object>': type 'A<Object>' is not a subtype of type 'A<bool>'
How can I cast b (a A<Object>) into a A<bool>?