DEV Community

Leticia @levxyca for Feministech

Posted on • Updated on

To never forget again: Stateless vs. Stateful in Flutter

If you landed here out of the blue and have no idea what I'm talking about, I recommend starting by reading this doc by Flutter that explains "What is Flutter?".

Nice to meet you, I'm Leticia @levxyca, and I'm on a quest to become the sorceress of Flutter, or maybe the Flutterfly 🦋 Today, I'm here writing about Stateless and Stateful in Flutter so I won't forget anymore, or at least I'll try haha.

Stateless Widget

A Stateless Widget is a widget without state control. But what does that mean? It means this type of widget doesn't have dynamic changes, in other words, the information there is static and doesn't change throughout the process.

class WidgetExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container();
  }
}
Enter fullscreen mode Exit fullscreen mode

Stateful Widget

Now, talking about the Stateful Widget, it's a widget with state control. This means we can have information that changes throughout the process, so it's with this widget that we can build various interactive things.

class WidgetExample extends StatefulWidget {
  const WidgetExample({super.key});

  @override
  State<WidgetExample> createState() => _WidgetExample();
}
Enter fullscreen mode Exit fullscreen mode

Does it make a bit more sense now?

I hope so! These are very important concepts when creating applications using Flutter 💙 If you have another way to define these concepts, feel free to comment below!

Top comments (0)