Created
April 10, 2020 01:13
-
-
Save erluxman/f87dddb2f48f1d1ef0f25903af1ded58 to your computer and use it in GitHub Desktop.
Richtext demo with different syles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: MyWidget(), | |
), | |
), | |
); | |
} | |
} | |
class MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return RichText( | |
text: TextSpan( | |
style: TextStyle( | |
fontSize: 30, | |
), | |
children: [ | |
TextSpan( | |
text: 'The RichText widget displays text that uses multiple different styles.', | |
style: TextStyle( | |
color: Colors.green, | |
decoration: TextDecoration.underline, | |
), | |
), | |
TextSpan( | |
text: 'The Text ', | |
style: TextStyle( | |
color: Colors.red, | |
), | |
), | |
TextSpan( | |
text: 'to display is described using a tree of TextSpan objects, each of which has an associated style that is used for that subtree. ', | |
style: TextStyle( | |
color: Colors.green, | |
), | |
) | |
]), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment