I am having problem with understanding how iterable
's whereType
works.
I have following example and I have no idea why it is behaving this way. Having this code:
List<dynamic> list = ["SomeString", 12];
print(list);
print(list.whereType<String>());
print(list.where((item) => item is String));
The output is:
[SomeString, 12]
(SomeString, 12)
(SomeString)
I would expect only String in second print. Could someone explain to me why I am wrong?
I think this is an inconsistency because whereType
is designed for Dart2 but Dart2 is not complete.
There is an open issue that looks similar
dart --reify-generic-functions my_script.dart
should make it work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With