Generate valid functions with optional non-nullable arguments
If a method of a mocked class returns a function with optional
yet non-nullable argument, Mockito currently produces something
like
(int x, {int y}) => /* doesn't matter */
which is not a valid Dart, since y must either be required or
have a default value. required won't fit into the desired type
and coming up with a default value is not easy, since it has to
be a constant, but dummyValue doesn't always produce one.
Fortunately, we can just widen the type here and make it nullable.
Generate valid functions with optional non-nullable arguments
If a method of a mocked class returns a function with optional yet non-nullable argument, Mockito currently produces something like
which is not a valid Dart, since
y
must either berequired
or have a default value.required
won't fit into the desired type and coming up with a default value is not easy, since it has to be a constant, butdummyValue
doesn't always produce one.Fortunately, we can just widen the type here and make it nullable.