Skip to content

Instantly share code, notes, and snippets.

@stegrams
Created May 2, 2020 22:31
Show Gist options
  • Select an option

  • Save stegrams/5b917435df6d58bb34fa6d9c34a9d0d4 to your computer and use it in GitHub Desktop.

Select an option

Save stegrams/5b917435df6d58bb34fa6d9c34a9d0d4 to your computer and use it in GitHub Desktop.
Container for a text with special background color for the first words
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