-2

Good morning. Because my flatButton is deprecated, I've tried to convert it to a TextButton. But now it doesn't work.

This was my working FlatButton code:

Flexible(
                        flex: 4,
                        child: FlatButton.icon(
                          shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(8)),
                          onPressed: () {

                            Get.to(AddTaskPage());
                          },
                          color: Colors.orange[900],
                          icon: Icon(
                            Icons.add,
                            color: Colors.white,
                          ),
                          label: Text("Add Task",
                              style:
                                  regularBoldTxt.copyWith(color: Colors.white)),
                        ),
                      )

This is the code of the conversion to Textbutton:

                      Flexible(
                        flex: 4,
                        child: TextButton(
                        style: TextButton.styleFrom(
                          shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(8)),
                          onPressed: () {

                            Get.to(AddTaskPage());
                          },
                          textStyle: TextStyle(
                          color: Colors.orange[900],
                          icon: Icon(
                            Icons.add,
                            color: Colors.white,
                          ),
                          label: Text("Add Task",
                              style:
                                  regularBoldTxt.copyWith(color: Colors.white)),
                        )),
Gavin
  • 11
  • 2

1 Answers1

0

This question has previously been answered I think https://stackoverflow.com/a/66805843/3550161

In your case it may be:

TextButton(
    style: flatButtonStyle,
    onPressed: () {
      Get.to(AddTaskPage());
    },
    child: Text(
      "Add Task",
      style: TextStyle(color: Colors.white),
    ),
bitFez
  • 184
  • 1
  • 12