In Dart type aliases can be declared via function type aliases typedef void F()
or generic function type aliases typedef F =
void Function()
. Generic function type aliases can be parametrized typedef Compare<T> = int Function(T a, T b);
. Function
type aliases miss this feature.
While it’s not always needed to have them parametrized, for the sake of readability it’s recommended to use consistent way of declaring type
aliases.
Thus, generic function type aliases should be preferred.
Noncompliant code example
typedef void F(int a);
Compliant solution
typedef F = void Function(int a)