代码之家  ›  专栏  ›  技术社区  ›  kartheeki j

如何从flutter中的dart文件调用android活动

  •  0
  • kartheeki j  · 技术社区  · 6 年前

    有人能告诉我如何从flutter中的dart文件调用android活动吗? 谢谢您。

    代码:

    class FlutterScreen extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('Screen'),
          ),
          body: Center(
            child: RaisedButton(
              child: Text('Android'),
              onPressed: () {
                // Navigate to Android activity screen when tapped!
              },
            ),
          ),
        );
      }
    }
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   rmtmckenzie    6 年前

    我想你要找的是 android_intent library .

    有了它,很容易触发一个意图。您必须确保在ios上使用它的方式不同,尽管ios不受支持。

    来自android_intent自述文件的示例代码:

    if (platform.isAndroid) {
      AndroidIntent intent = new AndroidIntent(
          action: 'action_view',
          data: 'https://play.google.com/store/apps/details?'
              'id=com.google.android.apps.myapp',
          arguments: {'authAccount': currentUserEmail},
      );
      await intent.launch();
    }