Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!
          },
        ),
      ),
    );
  }
}
like image 870
kartheeki j Avatar asked Nov 18 '25 10:11

kartheeki j


1 Answers

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();
}
like image 106
rmtmckenzie Avatar answered Nov 20 '25 22:11

rmtmckenzie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!