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

1 Answer 1

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),
    ),
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.