Home > Software engineering >  Change TextButton border colour - flutter
Change TextButton border colour - flutter

Time:10-07

I have added a border to my TextButton but am not sure how to change its colour (only outline colour not background):

TextButton(
              style: ButtonStyle(
                  shape: MaterialStateProperty.all(RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(0)))),
              onPressed: () {
                replacePoints();
              },
              child: Text(
                "${AppLocalizations.of(context)!.replacePoints}  ",
                style: TextStyle(color: Colors.white),
              ))

Thanks in advanced.

CodePudding user response:

Try this:

TextButton(
    style: ButtonStyle(
        shape: MaterialStateProperty.all(RoundedRectangleBorder(
            side: BorderSide(
              color: Colors.red, // your color here
              width: 1,
            ),
            borderRadius: BorderRadius.circular(0)))),
    onPressed: () {
      replacePoints();
    },
    child: Text(
      "${AppLocalizations.of(context)!.replacePoints}  ",
      style: TextStyle(color: Colors.white),
    ))

CodePudding user response:

Try below code you will change Border color in two ways

  1. Using TextButton.styleFrom refer image

    1. Using ButtonStyle Class refer image

  • Related