Employers in Accra and remote teams often name a state management approach in their adverts: Provider, Riverpod and Bloc came up in several of the ones we read. You do not need to master all of them. You need to understand what state is, how Flutter rebuilds screens when it changes, and why apps grow out of the simplest approach.
State causes rebuilds
In Flutter, the screen is a picture of your state. When the state changes, Flutter calls build again and redraws what changed. Your job is to change state in the right way so Flutter knows to redraw.
Local state with setState
For state that only one widget cares about, use a StatefulWidget and setState:
class Counter extends StatefulWidget {
const Counter({super.key});
@override
State<Counter> createState() => _CounterState();
}
class _CounterState extends State<Counter> {
int plates = 0;
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () => setState(() => plates++),
child: Text('Plates: $plates'),
);
}
}Calling setState tells Flutter "this changed, please rebuild". If you change plates without , the number changes in memory but the screen does not update. This is a very common beginner bug.