How do I open an external url in flutter web in new tab or in same tab

后端 未结 5 849
梦如初夏
梦如初夏 2021-02-18 23:16

I have a simple web app I have created with flutter web. I would like to know how I can open new an external url either in a new tab or in the sa

5条回答
  •  北荒
    北荒 (楼主)
    2021-02-18 23:35

    I think you want this — dart:js enables interoperability between Dart and JS —:

    import 'dart:js' as js;
    
    // ...
    
    FlatButton(
      child: Text('Button'),
      onPressed: () {
        js.context.callMethod('open', ['https://stackoverflow.com/questions/ask']);
      },
    )
    

提交回复
热议问题