Minimal Hello World Flutter App

Last reviewed by Frank Treacy
with Flutter 1.10.15

Need quick access to a minimal “Hello World” style app in Flutter?

Here it is!

// lib/main.dart

import 'package:flutter/widgets.dart';

main() => runApp(
  Center(
    child: Text(
      'Hello Flutter!', textDirection: TextDirection.ltr
    )
  )
);

How about a stateful minimal app?

// lib/main.dart

import 'package:flutter/widgets.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

main() => runApp(MyApp());

class MyApp extends HookWidget {
  @override
  Widget build(context) {
    final counter = useState(0);
    return GestureDetector(
      onDoubleTap: () => counter.value++,
      child: Center(
        child: Text(
          'Counter: ${counter.value}',
          textDirection: TextDirection.ltr,
        ),
      ),
    );
  }
}

Looking for a Material-style minimal app?

// lib/main.dart

import 'package:flutter/material.dart';

main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(context) {
    return MaterialApp(
      title: 'My Flutter App',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter Igniter!'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}

Did you find it useful?

The best from the Flutter-verse in 3 minutes or less? Join Snacks!

Delivered twice monthly. No link walls. No spam. EVER.