-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Lint for AnimatedBuilder/ValueListenableBuilder's child property #58551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yeah the AnimatedBuilder case is particularly tricky because you have no way to know what the incoming Listenable is actually telling you. It could be "the time has changed" and somewhere else you use The ValueListenableBuilder one is great though, that one should be much easier to do. |
Does an annotation on const ValueListenableBuilder({
...
@notNull
this.child,
}); See also: flutter/flutter#91616 |
It's common to not have a child. |
This one is a bit different. It's saying you should use // a ValueWidgetbuilder
Widget buildWidget(BuildContext context, double value, Widget child) {
return SizedBox(
height: value,
child: ColoredBox(color: Colors.red),
);
} The idea is the analyzer could possibly detect that |
Perhaps something on @widgetTreeBelowLastUsage(variableName: 'value', shouldUse: 'child')
typedef ValueWidgetBuilder<T> = Widget Function(BuildContext context, T value, Widget? child); |
(I'm not fond of that name but you get the idea hopefully) |
BAD:
GOOD:
Similar for
ValueListenableBuilder
, but that one might be easier because the actual value we're interested in is part of the method signature (so no need to correlatesomeAnimation
as in theAnimatedBuilder
)./cc @Hixie
The text was updated successfully, but these errors were encountered: