Closed WanderingFire2001 closed 4 years ago
I agree with effective dart that it is confusing for users to receive FutureOr
because they are required to cast before they know whether it is a Future
or not.
My initial proposal only recommended FutureOr
in case void
is returned. This would be fine because users aren't interested in the value and never have to cast.
It seems like it was also changed for all the other methods as well. I don't think this is necessary. Return type R
was/is fine.
@passsy @astralstriker we should make a decision on this and close this ASAP as many users are getting confused with FutureOr.
The update to 0.3 modified when() and its new sibling methods to return FutureOr.
The Effective Dart advice is to use FutureOr as a parameter, but not to return it. They advise instead to just return Future, as it will be more clear to users (who need to await the result either way).
https://dart.dev/guides/language/effective-dart/design#avoid-using-futureort-as-a-return-type
So the generator would produce
with Future / async instead of FutureOr
(That may also save you from having to document how to use the return types, as many of your users won't have experience dealing with a FutureOr return.)
Thanks for the new whenXXX methods, and for fixing the generation of null props for
@objects
!