farouk sherif
farouk sherif

Reputation: 93

After upgrade Flutter 3.3.0 RaisedButton showing error: The method 'FlatButton' isn't defined for the type 'CartScreen'. (undefined_method

Editor with error messages

FlatButton(
  child: Text('ORDER NOW'),
  onPressed: () {
    Provider.of<Orders>(context, listen: false).addOrder(
      cart.items.values.toList(),
      cart.totalAmount,
    );
    cart.clear();
  },
  textcolor: Theme.of(context).primaryColor,

Upvotes: 8

Views: 26228

Answers (3)

Piyush Sengar
Piyush Sengar

Reputation: 1

Simply add velocity_x: ^3.2.1 in your pubsec.yaml file

Upvotes: 0

Md. Yeasin Sheikh
Md. Yeasin Sheikh

Reputation: 63604

You can check breaking-changes/buttons

enter image description here

To have the same visual look

final ButtonStyle flatButtonStyle = TextButton.styleFrom(
  foregroundColor: Colors.black87,
  minimumSize: Size(88, 36),
  padding: EdgeInsets.symmetric(horizontal: 16.0),
  shape: const RoundedRectangleBorder(
    borderRadius: BorderRadius.all(Radius.circular(2.0)),
  ),
);

TextButton(
  style: flatButtonStyle,
  onPressed: () { },
  child: Text('Looks like a FlatButton'),
)

You can find more about restoring-the-original-button-visuals

Upvotes: 22

孙开宇
孙开宇

Reputation: 21

According to the Flutter 3.3.0 release notes, the deprecated RaisedButton was removed in GitHub pull request #98547.

Upvotes: 2

Related Questions