Flutter Introduction
Flutter is Google's open-source UI toolkit for building apps that run on Android, iOS, the web, Windows, macOS and Linux — all from a single codebase written in Dart. You have already learned the Dart language in the previous section; now you will use it to draw real user interfaces.
What makes Flutter different?
Most cross-platform frameworks translate your code into the native buttons and text fields of each platform. Flutter takes another route: it ships its own rendering engine and paints every pixel itself. A Flutter button looks and behaves the same on a phone, in a browser and on a desktop, because Flutter draws it.
| Feature | What it means for you |
|---|---|
| One codebase | Write the app once, build it for six platforms |
| Everything is a widget | Text, padding, layouts and whole screens are all composable widgets |
| Hot reload | See code changes in the running app in under a second, without losing state |
| Own rendering engine | Pixel-perfect, consistent UI and smooth 60–120 fps animations |
| Compiled to native code | Release builds compile Dart ahead-of-time to fast machine code |
Who uses Flutter?
Flutter powers apps from startups as well as large companies — banking apps, e-commerce, media players, internal business tools and games. Its sweet spot is any app with a custom, branded design that must look identical on every device.
A first look at Flutter code
A Flutter app is a Dart program whose main() function calls runApp() with a widget. Widgets are small, immutable descriptions of part of the UI. Here is the smallest useful app:
import 'package:flutter/material.dart';
void main() {
runApp(
const MaterialApp(
home: Scaffold(
body: Center(
child: Text('Hello, Flutter!'),
),
),
),
);
}Read it from the outside in:
MaterialAppsets up the app with Google's Material Design look.Scaffoldgives you a blank screen layout (later you will add an app bar, buttons and more).Centerplaces its child in the middle of the available space.Textdisplays a string.
Widgets are nested inside each other through child (or children) parameters. This nesting is called the widget tree.
Note: Flutter cannot run inside this website. Flutter examples are marked as simulated: pressing ▶ Run shows a preview mock-up of what the app looks like on a phone. Pure Dart examples in this course run for real.
Adding an app bar
Let's make it look like a real app by giving the Scaffold an AppBar:
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('My First App'),
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
),
body: const Center(
child: Text('Welcome to Flutter', style: TextStyle(fontSize: 24)),
),
),
);
}
}This time the UI lives in a class, MyApp, that extends StatelessWidget and overrides build(). That is the standard shape of almost every Flutter app — you will study it in detail in the StatelessWidget lesson.
Hot reload
During development you run the app on a phone, emulator or browser with flutter run. When you save a file, Flutter injects the changed code into the running app and rebuilds the widget tree. Your counter values, scroll positions and form input survive. This tight feedback loop is one of the main reasons developers enjoy Flutter.
Tip: Press
rin the terminal runningflutter runfor a hot reload, orRfor a full hot restart that resets the app state.
What you will learn
- Flutter Basics — installing Flutter, project structure, widgets, layout and styling.
- Building Apps — forms, lists, navigation, themes, state management, networking, animations and testing.
- Practice — exercises and a complete todo app built step by step.
Test yourself
Which programming language are Flutter apps written in?
- Kotlin
- JavaScript
- Dart
- Swift
Which function starts a Flutter app by attaching the root widget to the screen?
- startApp()
- runApp()
- main()
- build()
What does hot reload do?
- Reinstalls the app from scratch
- Injects changed code into the running app while keeping its state
- Clears the build cache
- Publishes the app to the store