Intro
Flutter is Googles UI toolkit: one Dart codebase compiles to iOS, Android, web, desktop. Pixel-perfect across platforms because Flutter draws its own widgets.
Flutter — what it is
EXAMPLE
import 'package:flutter/material.dart';
// ===== The model =====
// - Dart language (statically typed, JIT in dev, AOT in prod)
// - Flutter draws every pixel via Skia / Impeller (no native widgets)
// - Composable widgets; UI = f(state)
// - Hot reload is genuinely instant
// - One codebase, six platforms (iOS, Android, web, Windows, macOS, Linux)
// ===== Hello, Flutter =====
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(useMaterial3: true),
home: const Counter(),
);
}
}
class Counter extends StatefulWidget {
const Counter({super.key});
@override
State<Counter> createState() => _CounterState();
}
class _CounterState extends State<Counter> {
int _n = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Counter')),
body: Center(child: Text('Clicks: $_n', style: const TextStyle(fontSize: 24))),
floatingActionButton: FloatingActionButton(
onPressed: () => setState(() => _n++),
child: const Icon(Icons.add),
),
);
}
}
// ===== State management options =====
// Provider, Riverpod, Bloc, GetX, Zustand-like
// Choose one; mixing them across a codebase causes pain
// ===== When Flutter wins =====
// - Pixel-perfect UIs across iOS + Android
// - Teams that want one stack for mobile + desktop + web
// - Apps with custom UIs that should look identical everywhere
// - Material/Cupertino designs out of the box
// ===== When Flutter hurts =====
// - You need native look-and-feel that adopts OS updates instantly
// - SEO-critical web (Flutter web is canvas-based; not for blogs)
// - Heavy native-API needs (FFI is great but extra work)
// ===== Patterns to internalise =====
// - Compose small widgets; const constructors for free perf
// - setState locally; lift state when shared
// - Use ListView.builder for lazy lists
// - Use 'flutter analyze' + 'dart format' in CI
// ===== Pitfalls =====
// - StatefulWidget for everything -> hard to test; prefer StatelessWidget + a state lib
// - Overlong build() methods -> extract widgets
// - Forgetting const constructors -> avoidable rebuilds
// - Treating BuildContext like a global -> careful with async + context
Why it matters
Flutter draws its own UI, which is its biggest strength and its biggest trade-off. One Dart codebase ships to mobile, web, and desktop with consistent pixels. Reach for it when you want to control every pixel and the team is willing to invest in Dart and a single state-management choice.
Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.
Example
Example
// Flutter: Google's SDK, single codebase → iOS, Android, web, desktop. // UI is composed of Widgets; layout is reactive and declarative.Try it Yourself »
Discussion
Loading…