From 8f024da45ca69915fd3275a334483cfeca6f295d Mon Sep 17 00:00:00 2001 From: Dawn Rose <63545980+tastethedream@users.noreply.github.com> Date: Tue, 6 Dec 2022 18:59:32 +0000 Subject: [PATCH] Update ex11-5.md Missing example added to reflect QC2 section 12.6 --- ch11/ex11-5.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/ch11/ex11-5.md b/ch11/ex11-5.md index db93f60..2618517 100644 --- a/ch11/ex11-5.md +++ b/ch11/ex11-5.md @@ -3,4 +3,42 @@ # Example ```dart + +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 paramTitle = 'My Title'; + const paramName = 'My Name'; + return MaterialApp( + title: paramTitle, + home: Scaffold( + appBar: AppBar( + title: const Text(paramTitle), + ), + body: const MyTextWidget(name: paramName, title: paramTitle), + ), + ); + } +} + +class MyTextWidget extends StatelessWidget { + final String title; + final String name; + const MyTextWidget({Key? key, required this.title, required this.name}) + : super(key: key); + @override + Widget build(BuildContext context) { + return Center( + child: Text("$title $name"), + ); + } +} + ```