YouTip LogoYouTip

Flutter Tutorial - Getting Started

What is Flutter?

Flutter builds cross-platform mobile apps with Dart.

Widget

class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
        return MaterialApp(
            home: Scaffold(
                appBar: AppBar(title: Text("Flutter")),
                body: Center(child: Text("Hello!")),
            ),
        );
    }
}

StatefulWidget

class Counter extends StatefulWidget {
    @override
    _CounterState createState() => _CounterState();
}

class _CounterState extends State<Counter> {
    int count = 0;
    @override
    Widget build(BuildContext context) {
        return Column(children: [
            Text("Count: $count"),
            ElevatedButton(
                onPressed: () => setState(() => count++),
                child: Text("Add"),
            ),
        ]);
    }
}

Summary

  • Everything is a widget in Flutter
  • setState triggers UI rebuild
← Swift Tutorial - Getting StartiOS Tutorial - Getting Started β†’