如何在一个按钮中执行2种不同的动作?

问题描述 投票:0回答:2

示例如何在一个按钮中同时打开网址和小吃栏?

 onTap: () => launch("http://flutter.dev"),
 // when button tapped then url will be open and displaying a snackbar at a time
flutter button dart
2个回答
0
投票

onTap: () { firstFunction(); secondFunction(); },

如果我误解了您的问题,请发表评论。


0
投票

丢弃箭头功能并这样写

     onTap: (){
        launch("http://flutter.dev");
        Scaffold.of(context).showSnackBar(SnackBar(content: Text("Message here"),));
      },
© www.soinside.com 2019 - 2024. All rights reserved.