avoid-empty-setstate
- Group
- Correctness
- Path
lint/correctness/avoid-empty-setstate- Default
- On (recommended)
- Origin
- Falcon
- Domain
- flutter
- Rule
- 60 of 512
Avoid setState callbacks with empty block bodies. Comments and empty statements do not update state; unrelated methods are ignored.
Invalid
import 'package:flutter/material.dart';
class S extends State<StatefulWidget> { void update() {
setState(() { ; });
setState(() { /* comment */ });
this.setState(() {});
setState((() {}));
setState(() { ; ; });
}}class S extends State<StatefulWidget> { void update() {setState(() { ; });setState(() { ; });setState(() { /* comment */ });setState(() { /* comment */ });this.setState(() {});this.setState(() {});setState((() {}));setState((() {}));setState(() { ; ; });Valid
import 'package:flutter/material.dart';
class S extends State<StatefulWidget> { int x = 0; void update() {
setState(() { x++; });
setState(() => x++);
this.setState(() { x = 2; });
setState(() { update(); });
setState(() { if (x == 0) x = 1; });
}}Configure avoid-empty-setstate
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"correctness": {
"avoid-empty-setstate": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/correctness/avoid-empty-setstate: <reason>More correctness rules
- avoid-empty-test-groupstest
Reports inline framework groups without any test registrations.
- avoid-global-state
avoid-global-stateDisallow mutable global and static state.
- avoid-hooks-outside-buildrecommendedflutter_hooks
Flags confirmed Flutter hooks outside hook builds, custom hooks, and HookBuilder/HookConsumer builders.
- avoid-incorrect-image-opacityflutter
Flags Opacity directly wrapping a Flutter Image, including named constructors.
- avoid-inherited-widget-in-initstaterecommendedflutter
Avoid inherited-widget subscriptions during initState.
- avoid-instantiating-in-value-providerprovider
Value providers borrow existing instances; newly constructed values need create.
- avoid-late-contextrecommendedflutter
Avoid storing
BuildContextin late fields or reading it in late initializers. - avoid-missing-completer-stack-trace
Preserve error origins when calling SDK
Completer.completeError.