DEV Community

Leticia @levxyca for Feministech

Posted on • Edited on

2 2 2 2 2

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!

Sentry mobile image

Mobile Vitals: A first step to Faster Apps

Slow startup times, UI hangs, and frozen frames frustrate users—but they’re also fixable. Mobile Vitals help you measure and understand these performance issues so you can optimize your app’s speed and responsiveness. Learn how to use them to reduce friction and improve user experience.

Read the guide →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs