Search code examples
flutterdart

Change TextButton border colour - flutter


I have added a border to my TextButton.

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

How can I change its colour (only outline colour not background)?


Solution

  • 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),
        ))