简体   繁体   中英

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

带有错误消息的编辑器

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,

You can check breaking-changes/buttons

在此处输入图像描述

To have the same visual look

final ButtonStyle flatButtonStyle = TextButton.styleFrom(
  primary: 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM