Open
Description
When you have redirecting factory constructor you almost always have the same parameters as the target. It would be convenient (and less error prone) to be allowed to omit parameters to specify that the parameters are the same as the target.
//---------today
class A {
factory A({String? p1, required int p2, required int? p3}) = _A;
}
class _A implements A {
_A({String? p1, required int p2, required int? p3});
}
//--------- with the proposal
class A {
factory A = _A;
}
class _A implements A {
_A({String? p1, required int p2, required int? p3});
}
Moreover this feature would have avoid a bug in the Flutter migration to nullsafety because there was a similar case where the A class was migrated as below:
class A {
factory A({String p1, required int p2, required int p3}) = _A; // no question mark added
}
class _A implements A {
_A({String? p1, required int p2, required int? p3});
}
and this code doesn't trigger any issue unless you have a call like A(p3: null)
is your codebase.