I want to give color to the text background like the picture below:
while mine is still like this:
And the code that I have written is like this:
Text(
'Last Activity',
style: TextStyle(
fontSize: 16,
color: ColorName.whitePrimary,
),
),
CodePudding user response:
body: Center(
child: TextButton.icon(
style: TextButton.styleFrom(
textStyle: TextStyle(color: Colors.blue),
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6.0),
),
),
onPressed: () => {},
icon: Text('Last Activity'),
label: Icon(Icons.chevron_right),
),
),
CodePudding user response:
Set the style
parameter in your Text
widget:
Text(
'Hello, World!',
style: TextStyle(fontSize: 32, backgroundColor: Colors.green),
);
See also
-
2. Using Row
GestureDetector( onTap: () {}, child: Container( height: 30,//change on your need width: 120,//change on your need padding: const EdgeInsets.all(5), alignment: Alignment.center, color: const Color.fromRGBO(60, 75, 175, 1), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: const [ Text( 'Last Activity', style: TextStyle( color: Colors.white, ), ), Icon( Icons.chevron_right, color: Colors.white, ), ], ), ), ),
CodePudding user response:
Try the following code:
Text( 'Last Activity', style: TextStyle( fontSize: 16, color: ColorName.whitePrimary, ), ),