Skip to content

Instantly share code, notes, and snippets.

@iapicca
Last active August 29, 2022 08:25
Show Gist options
  • Select an option

  • Save iapicca/ef1a43907d1f2a5cb6a64f44cdec7662 to your computer and use it in GitHub Desktop.

Select an option

Save iapicca/ef1a43907d1f2a5cb6a64f44cdec7662 to your computer and use it in GitHub Desktop.
extension do not warn for error
import 'dart:async';
typedef Nullary<T> = T Function();
typedef NullaryAsync<T> = Nullary<Future<T>>;
typedef NullaryFutureOr<T> = Nullary<FutureOr<T>>;
typedef Unary<T, S> = T Function(S);
typedef UnaryAsync<T, S> = Unary<Future<T>, S>;
typedef UnaryFutureOr<T, S> = Unary<FutureOr<T>, S>;
extension NullaryFutureOrToNullaryAsync<T> on NullaryFutureOr<T> {
NullaryAsync<T> get future => call();
}
extension UnaryFutureOrToUnaryAsync<T, S> on UnaryFutureOr<T, S> {
UnaryAsync<T, S> get future => call();
}
FutureOr<void> nullary() {}
FutureOr<void> unary(dynamic _) {}
void main() {
print(nullary.future.runtimeType);
print(unary.future.runtimeType);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment