flutter-in-action icon indicating copy to clipboard operation
flutter-in-action copied to clipboard

FlatButton已经不推荐使用了

Open 18334581089 opened this issue 3 years ago • 3 comments

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,谢谢了)

18334581089 avatar Mar 17 '21 03:03 18334581089

同上

toKnowMore avatar Mar 23 '21 05:03 toKnowMore

+1

Hwy152 avatar Apr 21 '21 07:04 Hwy152

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

ltybenet avatar May 16 '21 04:05 ltybenet