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), ), ], ), ); } } - ```