From c176a3d44e0b6c8f915091d5eb65e07a1aeb0622 Mon Sep 17 00:00:00 2001 From: Dawn Rose <63545980+tastethedream@users.noreply.github.com> Date: Tue, 6 Dec 2022 14:51:16 +0000 Subject: [PATCH] Update ex9-4.md Code updated to reflect QC2 section 10.4 --- ch09/ex9-4.md | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/ch09/ex9-4.md b/ch09/ex9-4.md index cc1ac26..2ee0315 100644 --- a/ch09/ex9-4.md +++ b/ch09/ex9-4.md @@ -6,46 +6,46 @@ ```dart import 'package:flutter/material.dart'; -void main() => runApp(const MyApp()); +void main() { + runApp(const MyApp()); +} class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Example'; - @override Widget build(BuildContext context) { - return const MaterialApp( - title: _title, - home: MyStatelessWidget(), + const title = 'Expanded Widget'; + return MaterialApp( + title: title, + home: Scaffold( + appBar: AppBar( + title: const Text(title), + ), + body: const MyExpandedWidget(), + ), ); } } -class MyStatelessWidget extends StatelessWidget { - const MyStatelessWidget({Key? key}) : super(key: key); - +class MyExpandedWidget extends StatelessWidget { + const MyExpandedWidget(); @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: const Text('Placeholder Example')), - body: _buildPlaceholderWidget(), - ); - } - - Widget _buildPlaceholderWidget() { return Column( - children: const [ - Placeholder(fallbackHeight: 400, strokeWidth: 10, color: Colors.red), + children: const [ + Expanded( + child: Placeholder( + fallbackHeight: 400, strokeWidth: 10, color: Colors.red), + ), Expanded( - child: Text("Expanded Text") + child: Placeholder( + fallbackHeight: 400, strokeWidth: 10, color: Colors.white), ), - Placeholder(fallbackHeight: 200, strokeWidth: 5, color: Colors.green), Expanded( - child: Text("Expanded Text") + child: Placeholder( + fallbackHeight: 400, strokeWidth: 10, color: Colors.blue), ), - Placeholder(fallbackHeight: 100, strokeWidth: 1, color: Colors.blue), - ] + ], ); } }