Flutter Overview
45.1 What is Flutter?
Google's UI toolkit for building natively compiled apps for mobile, web, desktop, and embedded from a single Dart codebase. It renders with its own engine (Impeller/Skia), uses widgets for everything, and supports hot reload.
import 'package:flutter/material.dart';
void main() => runApp(const CounterApp());
class CounterApp extends StatelessWidget {
const CounterApp({super.key});
@override
Widget build(BuildContext context) => MaterialApp(
title: 'Counter',
theme: ThemeData(colorSchemeSeed: Colors.indigo, useMaterial3: true),
home: const CounterPage(),
);
}
class CounterPage extends StatefulWidget {
const CounterPage({super.key});
@override
State<CounterPage> createState() => _CounterPageState();
}
class _CounterPageState extends State<CounterPage> {
int _count = 0;
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('Flutter Counter')),
body: Center(
child: Text('Pressed $_count times', style: Theme.of(context).textTheme.headlineMedium),
),
floatingActionButton: FloatingActionButton(
onPressed: () => setState(() => _count++),
child: const Icon(Icons.add),
),
);
}45.2 Core Flutter Concepts
Immutable UI descriptions: StatelessWidget, StatefulWidget, InheritedWidget Element and RenderObject trees
The framework's internal layers (build → layout → paint) Row, Column, Stack, Expanded, Flexible, Container, Padding, SizedBox, constraints ("constraints go down, sizes go up")
ListView.builder, GridView, slivers (CustomScrollView)
Navigator, go_router (declarative URL routing) ThemeData, Material 3, Cupertino widgets FutureBuilder, StreamBuilder
Platform channels (MethodChannel), pigeon (type-safe), FFI, plugins
Implicit (AnimatedContainer), explicit (AnimationController), Hero, Rive/Lottie
Unit, widget (testWidgets), golden, integration tests Build and release
flutter build apk/appbundle/ipa/web/windows/macos/linux, flavors, obfuscation (--obfuscate --split-debug-info)