avoid-empty-setstate
preset: recommended
Warns when a setState
callback is empty.
Example
❌ Bad:
class _FooState extends State<StatefulWidget> {
Widget build(context) {
return FooWidget(
onChange: (value) async {
setState(() {}); // LINT
},
);
}
}
✅ Good:
class _FooState extends State<StatefulWidget> {
String _myState;
Widget build(context) {
return FooWidget(
onChange: (value) async {
setState(() {
_myState = 'changed';
});
},
);
}
}