From d0de95a9ee80ccf9cd331e7ce6889ab4131d33de Mon Sep 17 00:00:00 2001 From: Dawn Rose <63545980+tastethedream@users.noreply.github.com> Date: Tue, 6 Dec 2022 14:38:08 +0000 Subject: [PATCH] Update ex9-1.md Code updated to reflect QC2 section 10.2 --- ch09/ex9-1.md | 50 ++++++++++++-------------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/ch09/ex9-1.md b/ch09/ex9-1.md index 8dcd4cf..5d21e1b 100644 --- a/ch09/ex9-1.md +++ b/ch09/ex9-1.md @@ -11,11 +11,9 @@ void main() { class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); - @override Widget build(BuildContext context) { - const title = 'Rich Text'; - + const title = 'RichText Demo'; return MaterialApp( title: title, home: Scaffold( @@ -31,49 +29,25 @@ class MyApp extends StatelessWidget { double screenHeight = 0.0; class MyRichText extends StatelessWidget { - const MyRichText(); - + const MyRichText({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - screenHeight = MediaQuery.of(context).size.height/3; - - return SingleChildScrollView( - child: Column( + screenHeight = MediaQuery.of(context).size.height / 3; + return RichText( + text: const TextSpan( children: [ - Container( - height: screenHeight, - color: Colors.red, + TextSpan( + text: 'Hello', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24), ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox(height: screenHeight), - RichText( - text: const TextSpan( - children: [ - TextSpan( - text: 'Hello', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24), - ), - TextSpan( - text: 'Luxembourg', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 32, - color: Colors.grey), - ), - ], - ), - ), - ]), - Container( - height: screenHeight, - color: Colors.blue, + TextSpan( + text: 'Luxembourg', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 32, color: Colors.grey), ), ], ), ); } } - ```