You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That being said, to be clever, you could write a custom map function.
NOTE: This requires Dart2 semantics.
Iterable<Object> map3<A, B, C>(Iterable<Object> elements) sync* {
for (final e in elements) {
if (e isA) {
yieldnewGeneric(e);
}
if (e isB) {
yieldnewGeneric(e);
}
if (e isC) {
yieldnewGeneric(e);
}
}
}
main() {
var list = ["a", 1, newText("hello")];
map3<String, int, Text>(list).forEach((it) => it.runtimeType);
}
... should work as you intended. Obviously it's not a great general solution.
It seems like dart is losing the type when calling a generic constructor inside
map
(andreduce
). Is this intended? Is there a workaround?I did not expect this from a statically typed language.
Running with
Dart version 2.0.0-dev.41.0.flutter-2f68e82526
The text was updated successfully, but these errors were encountered: