Skip to content

Latest commit

 

History

History
52 lines (46 loc) · 1.08 KB

ex10-4.md

File metadata and controls

52 lines (46 loc) · 1.08 KB

10.4 Using a Placeholder widget

Example

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    const title = 'Expanded Widget';
    return MaterialApp(
      title: title,
      home: Scaffold(
        appBar: AppBar(
          title: const Text(title),
        ),
        body: const MyExpandedWidget(),
      ),
    );
  }
}

class MyExpandedWidget extends StatelessWidget {
  const MyExpandedWidget();
  @override
  Widget build(BuildContext context) {
    return Column(
      children: const [
        Expanded(
          child: Placeholder(
              fallbackHeight: 400, strokeWidth: 10, color: Colors.red),
        ),
        Expanded(
          child: Placeholder(
              fallbackHeight: 400, strokeWidth: 10, color: Colors.white),
        ),
        Expanded(
          child: Placeholder(
              fallbackHeight: 400, strokeWidth: 10, color: Colors.blue),
        ),
      ],
    );
  }
}