Debug School

rakesh kumar
rakesh kumar

Posted on

HOW CAN I CHANGE THE BACKGROUND COLOR OF A TEXTBUTTON IN FLUTTER?-FLUTTER

Output Screenshot:

SOLUTION

TextButton(
    child: Text('test'),
    style: ButtonStyle(backgroundColor: MaterialStateProperty.all(Colors.red)),
    onPressed: () {},
),
Enter fullscreen mode Exit fullscreen mode
TextButton( style: TextButton.styleFrom(backgroundColor: Colors.red), ),
Enter fullscreen mode Exit fullscreen mode
TextButton(
  onPressed: () {},
  child: Container(
    padding: EdgeInsets.fromLTRB(30, 10, 30, 10),
    color: Colors.red,
    child: Text(""),
  ),
)
Enter fullscreen mode Exit fullscreen mode
TextButton(
  child: Text('Example'),
  onPressed: () {},
  style: TextButton.styleFrom(backgroundColor: Colors.red),
)
Enter fullscreen mode Exit fullscreen mode

Full Summary:
style: ButtonStyle--backgroundColor: MaterialStateProperty.all
TextButton.styleFrom
TextButton--Container
TextButton---TextButton.styleFrom

Refrence
Click here

Top comments (0)