Flutter UI Widgets

Nov 9 2021 · Dart 2.14, Flutter 2.5, VS Code 1.61

Part 1: Flutter UI Widgets

02. Explore Basic Widgets

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 01. Understand Flutter's UI Approach Next episode: 03. Build Layouts

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Open the starter project for this episode in Visual Studio Code. I’m using version 1.60. Inside the main.dart file, you have the main method that runs the root widget of the application. The root widget; MyApp which is a stateless widget returns an empty Container in its build method. More on the Container widget later on.

...
  return const MaterialApp(
    title: 'Flutter UI Widgets',
    home: MainPage(),
  );
...
class MainPage extends StatelessWidget {
  const MainPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Flutter UI Widgets'),
      ),
      body: const Center(
        child: Text('Main Page'),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          print('Clicked');
        },
        child: const Icon(Icons.add),
      ),
    );
  }
}
...
return Container(
  margin: cosnt EdgeInsets.all(32),
  padding: cosnt EdgeInsets.all(16),
  width: 200,
  height: 200,
  color: Colors.green,
  child: const Text('Main Page'),
)
...
...
decoration: BoxDecoration(
  borderRadius: BorderRadius.circular(16),
  border: Border.all(width: 2.0, color: Colors.red),
  color: Colors.green,
),
...
...
child: Column(
  children: <Widget>[
    const Text('1'),
    const Text('2'),
    const Text('3'),
  ],
),
...
const Text('1', style: TextStyle(fontSize: 32)),
const Text('2', style: TextStyle(fontSize: 32)),
const Text('3', style: TextStyle(fontSize: 32)),
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch
Container(
  color: Colors.blue,
  child: const Text(
    '1',
    textAlign: TextAlign.center,
    style: TextStyle(fontSize: 32),
  ),
),
// Repeat this for the remaining 2 
textAlign: TextAlign.center