Skip to content

Instantly share code, notes, and snippets.

@erluxman
Created April 10, 2020 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erluxman/f87dddb2f48f1d1ef0f25903af1ded58 to your computer and use it in GitHub Desktop.
Save erluxman/f87dddb2f48f1d1ef0f25903af1ded58 to your computer and use it in GitHub Desktop.
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