What is the most important concept in Flutter?
In Flutter, everything you see on screen is a widget: text, buttons, padding, layouts, even the entire app itself.
Learn the core concept that makes Flutter tick. Everything is a widget.
Passing the Quiz & Exercises is mandatory to earn FX and proceed. If you fail, try again to gain the required FX, then the Proceed button will become available.
You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.
Having trouble? AI is here to help
Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.
Use the AI button at the bottom of the screen
The most important concept in Flutter is that everything is a widget.
A widget is a building block of your user interface. Think of widgets like Lego bricks. You combine small, simple widgets together to create complex and beautiful UIs. Every element you see on screen, from a piece of text to a button to an entire page layout, is a widget.
| UI Element | Widget Name | What It Does |
|---|---|---|
| Text | Text | Shows text on screen |
| Button | ElevatedButton | A clickable button |
| Image | Image | Displays an image |
| Text field | TextField | Accepts user input |
| Layout | Column, Row | Arranges children vertically or horizontally |
| Spacing | SizedBox, Padding | Adds space around or between widgets |
| Screen structure | Scaffold | Provides the basic app skeleton |
If you have used HTML before, you know about elements like div, p, and button. In Flutter, everything serves a similar purpose but they are all called widgets. Even padding, alignment, and gesture detection are implemented as widgets.
Your app UI is organized as a tree of widgets. Each widget can contain other widgets called children, forming a hierarchy. Here is a simple example:
MaterialApp
└── Scaffold
├── AppBar
│ └── Text("My App")
└── body: Center
└── Column
├── Icon(Icons.star)
├── SizedBox(height: 10)
└── Text("Hello!")
This tree structure is fundamental to how Flutter works. Flutter reads this tree and draws the corresponding UI on screen. Whenever something changes, Flutter rebuilds the affected part of the tree and updates the display.
Every widget in Flutter is either a StatelessWidget or a StatefulWidget. Understanding the difference between them is important.
Use a StatelessWidget when the UI does not need to update after it is built. For example, a simple text label or a static card.
1// StatelessWidget: Shows static content2class GreetingCard extends StatelessWidget {3final String name; // Data passed in (won't change)45const GreetingCard({required this.name});67@override8Widget build(BuildContext context) {9// build() returns the UI10// Called once, never changes11return Text('Hello, $name!');12}13}
Use a StatefulWidget when the UI needs to update based on user interaction or data changes. For example, a like button, a counter, a form input, or an animation.
1// StatefulWidget: UI can change2class LikeButton extends StatefulWidget {3@override4State<LikeButton> createState() => _LikeButtonState();5}67class _LikeButtonState extends State<LikeButton> {8bool isLiked = false; // This is the state. It can change over time.910@override11Widget build(BuildContext context) {12return IconButton(13icon: Icon(14isLiked ? Icons.favorite : Icons.favorite_border,15color: isLiked ? Colors.red : Colors.grey,16),17onPressed: () {18setState(() { // setState tells Flutter to rebuild the UI19isLiked = !isLiked; // Toggle the state20});21},22);23}24}
Start with StatelessWidget for most of your widgets. Only switch to StatefulWidget when you need the UI to change based on user interaction or data updates. We will cover this topic in much more detail later in the course.
Every widget must have a build() method that returns another widget. This method:
@override
Widget build(BuildContext context) {
return Text('I am a widget!'); // Must return a widget
}
Widgets are configured using their constructor parameters. You pass in values when creating a widget to control how it looks and behaves.
1// Text widget with styling2Text(3'Hello World', // Required: the text to show4style: TextStyle( // Optional: styling5fontSize: 24,6fontWeight: FontWeight.bold,7color: Colors.blue,8),9textAlign: TextAlign.center, // Optional: alignment10)1112// Container with decoration13Container(14width: 200, // Width in logical pixels15height: 100, // Height in logical pixels16padding: EdgeInsets.all(16),17decoration: BoxDecoration(18color: Colors.white,19borderRadius: BorderRadius.circular(12),20boxShadow: [BoxShadow(blurRadius: 5, color: Colors.black12)],21),22child: Text('Inside a container'),23)
| Category | Widgets |
|---|---|
| Text | Text, RichText, SelectableText |
| Buttons | ElevatedButton, TextButton, IconButton |
| Input | TextField, Checkbox, Switch, Slider |
| Layout | Column, Row, Stack, Wrap |
| Containers | Container, Card, SizedBox, Padding |
| Lists | ListView, GridView, ListTile |
| Navigation | AppBar, BottomNavigationBar, Drawer |
| Media | Image, Icon, CircleAvatar |
You do not need to memorize all of these right now. As you build more apps, you will naturally learn which widgets to use for different situations. We will cover the most important ones in detail throughout this course.
When building any screen, think in this order:
This sequence helps you avoid random trial-and-error and gives you a repeatable system for building UIs.
Name small reusable widgets early (for example ProfileHeader, StatRow). This builds better architecture habits from day one.
Learn the core concept that makes Flutter tick. Everything is a widget. Widgets are reusable UI blocks. You combine them like LEGO pieces to build screens.
Build confidence with basics first; speed comes later.
Sketch the widget tree first, then code from top to bottom.
Most Flutter productivity comes from understanding layout rules and composing widgets cleanly.
In Flutter, everything you see on screen is a widget: text, buttons, padding, layouts, even the entire app itself.
StatefulWidget is used when the widget's appearance can change over time: like toggles, counters, or form inputs.
The build() method describes the widget's UI and is called by Flutter's framework whenever the widget needs to be rendered.
setState() notifies Flutter that the internal state has changed, triggering a rebuild of the widget with the new data.
Something seems incorrect, unclear, or missing? Let us know.
FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.
Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.
Sign in to continue with exercises and quiz for this lesson.
Sign In to Continue