Flutter Tutorials and Knowledge Sharing…
In this article, I’m going to introduce Flutter state management, what a state is, what state management is and what are state management packages, and why they are used. And also, there are examples; one shows what the state is, another shows how to do State Management only flutter itself, and the third shows how to do state management using Riverpod. Here I’m going to explain the state of Flutter using the basic countering application that every flutter app starts.
class MyHomePage extends StatefulWidget {
const MyHomePage({
super.key,
});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Simple State"),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => FlutterState()),
);
},
child: const Text(…