flutterchina / flutter-in-action

《Flutter实战》书稿。第二版书稿已上传,请移步新Repo。
https://book.flutterchina.club
8.67k stars 1.7k forks source link

FlatButton已经不推荐使用了 #429

Open 18334581089 opened 3 years ago

18334581089 commented 3 years ago

2.2.1,当我使用vscode协商FlatButton时会提示. 信息如下 'FlatButton' is deprecated and shouldn't be used. Use TextButton instead. See the migration guide in flutter.dev/go/material-button-migration-guide). This feature was deprecated after v1.25.0-8.1.pre..

(本人刚开始学习flutter,使用的时2.0,谢谢了)

toKnowMore commented 3 years ago

同上

Hwy152 commented 3 years ago

+1

ltybenet commented 3 years ago

flutter 2020年8月更新 https://docs.google.com/document/d/1yohSuYrvyya5V1hB6j9pJskavCdVq9sVeTqSoEPsWH0/edit

FlatButton => TextButton

下面是修改后的代码

Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
      ... //省略无关代码
      TextButton(
          onPressed: (){
            Navigator.push(context, 
              MaterialPageRoute(builder: (context){
                return NewRoute();
              })
            );
          }, 
          child: Text("open new route"),
          style: ButtonStyle(
            foregroundColor: MaterialStateProperty.all(Colors.red)
          ),
          ),
       ],
 )