Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Richtext demo with different syles
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