Allow "void" as a generic type parameter. #17518
Labels
area-language
Dart language related items (some items might be better tracked at github.com/dart-lang/language).
closed-duplicate
Closed in favor of an existing report
type-enhancement
A request for a change that isn't a bug
The void type is only allowed as a function return type. It is equivalent to "Null" except for documentation purposes (and allowing "return;" statements in the body).
The documentation meaning is that the function does not return a meaningful value, and its result shouldn't be used.
For Future, we have the same documentation need. Some Futures carry no meaningful value, they are effectively the delayed results of evaluating a void function.
It would improve documentation if these futures could be typed as "Future<void>". By duality, it would be equivalent to "Future<Null>", but documenting a different intent.
It's likely to also be useful in other places. Perhaps we should allow "void" everywhere we currently allow "dynamic".
The text was updated successfully, but these errors were encountered: