skip to Main Content
Widget build(BuildContext context) {
    return Expanded(
      child: Container(
        alignment: Alignment.center,
        child: FlatButton(
          color: (buttons == EQUAL_SIGN)
              ? Theme.of(context).primaryColor
              : Color(0xFFFFFFFF),
          padding: EdgeInsets.symmetric(vertical: 10.0),
          child: Text(
            buttons,
            style: TextStyle(
                color: (_colorTextButtons())
                    ? Colors.blueAccent
                    : (buttons == EQUAL_SIGN)
                        ? Theme.of(context).buttonColor
                        : Color(0xFF444444),
                fontSize: _fontSize() ? 18 : 20.0),
          ),
          onPressed: () => onTap(buttonText: buttons),
        ),
      ),
    );
  }
}

I try to replace with TextButton but nothing.

Widget build(BuildContext context) {
return Expanded(
child: Container(
alignment: Alignment.center,
child: TextButton(
color: (buttons == EQUAL_SIGN)
? Theme.of(context).primaryColor
: Color(0xFFFFFFFF),
padding: EdgeInsets.symmetric(vertical: 10.0),
child: Text(
buttons,
style: TextStyle(
color: (_colorTextButtons())
? Colors.blueAccent
: (buttons == EQUAL_SIGN)
? Theme.of(context).buttonColor
: Color(0xFF444444),
fontSize: _fontSize() ? 18 : 20.0),
),
onPressed: () => onTap(buttonText: buttons),
),
),
);
}
}

2

Answers


  1. We don’t have any FlatButton on the current version of Flutter. You can use TextButton.

    enter image description here

    Find more about this breaking-changes/buttons.

    Login or Signup to reply.
  2. You can change the flatButton into some other button like textButton; it is due to update of Flutter that made the flatButton can’t be used anymore.

    Here is the example of simple usage textButton:

     TextButton(
         style: TextButton.styleFrom(
            textStyle: const TextStyle(fontSize: 20),
         ),
         onPressed: null,
            child: const Text('Disabled'),
         ),
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search