-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iterable.where() should be generic and return an iterable with the given type #27827
Comments
cc @bwilkerson |
I have had to deal with this issue too, but |
presumably if you don't give the type explicitly, it would just return an |
See flutter#6861 This silences all but two of the warnings from https://travis-ci.org/flutter/flutter/builds/176055550 One of the silenced warnings was a genuine code error. Some of the others were correct but there was no way for the analyzer to know, and I worked around them. The remainder are problems with the analyzer, specifically dart-lang/sdk#27827 and dart-lang/sdk#27504.
I'd rather add a new method to do type-filtering, like (I don't know what |
I'd be totally on board with ( |
See #6861 This silences all but two of the warnings from https://travis-ci.org/flutter/flutter/builds/176055550 One of the silenced warnings was a genuine code error. Some of the others were correct but there was no way for the analyzer to know, and I worked around them. The remainder are problems with the analyzer, specifically dart-lang/sdk#27827 and dart-lang/sdk#27504.
Just ran into this again. This is definitely going to become a bigger paint point in Dart 2.0. |
Is this now solved with Iterable.cast() and Iterable.retype()? |
The following works with main() {
Iterable<num> xs = [1, 2.2, 3, 4.2];
xs.whereType<int>()
.where((int i) => i > 1)
.forEach((int i) { print(i); }); // Prints '(3)'.
} The vm prints |
Once |
Dart 2.0 contains |
The following code is sound but the analyzer can't tell:
If
where
was defined asIterable<T> where<T extends E>(...)
then the above could work (might even work automatically given type inference?).The text was updated successfully, but these errors were encountered: