Created
May 2, 2020 22:31
-
-
Save stegrams/5b917435df6d58bb34fa6d9c34a9d0d4 to your computer and use it in GitHub Desktop.
Container for a text with special background color for the first words
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: Container( | |
| padding: EdgeInsets.all(20), | |
| color: Colors.cyan, | |
| width: 400, | |
| child: RichText( | |
| text: TextSpan( | |
| style: TextStyle( | |
| fontSize: 26, | |
| ), | |
| children: [ | |
| TextSpan( | |
| text: "Banner ", | |
| style: TextStyle(backgroundColor: Colors.red), | |
| ), | |
| TextSpan(text: "This is a news header, "), | |
| TextSpan(text: "This is a news header"), | |
| TextSpan(text: "This is a news header"), | |
| TextSpan(text: "This is a news header"), | |
| ], | |
| ), | |
| ), | |
| ), | |
| ), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment