简体   繁体   中英

how to call android activity from dart file in flutter

can anyone tell me how to call android activity from dart file in flutter. Thank you.

code:

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!
          },
        ),
      ),
    );
  }
}

I think what you're looking for is the android_intent library .

With it, it's easy to trigger an intent. You'll have to make sure that you don't use it the same way on iOS though as iOS isn't supported.

Example code from the android_intent readme:

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();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM