Closed navaronbracke closed 1 year ago
Please provide the type of someListenable
. ValueListenableBuilder<T>
should pick up the type of someListenable
. But it can't when someListenable
returns a dynamic type.
At best, provide a working dartpad with the issue ✌️
@passsy Turns out when the lower constraint is Dart 2.17, the analyzer doesn't enforce the check. Bumping to Dart 2.18.0 does fix it. My bad.
In
https://github.com/passsy/dart-lint/blob/master/lib/strict.yaml
the lintalways_specify_types
is disabled, which is then forwarded to the lints for packages.The comment indicates
This statement is not entirely true.
For example, I recently had to fix a bug in a package which had the following code:
Both the null check and the cast were unnecessary in this code. But, this is only surfaced after writing
ValueListenableBuilder<Foo>
, becauseValueListenableBuilder()
is actuallyValueListenableBuilder<dynamic>()
anddynamic
disables type checks.This bug is one of the reasons why
flutter_lints
does have this enabled.Maybe we should have a different lint, i.e.
always_specify_generic_type
?