How do I use multiple main activities in flutter?

1.7k Views Asked by At

I am building a flutter app which has these two plugins 1) local_auth 2) flutter_bar_code and they both use different main activities , for local auth the MainActivity.kt is like

import io.flutter.embedding.android.FlutterFragmentActivity

class MainActivity: FlutterFragmentActivity() {
      
  }

and for flutter bar code scanner the MainActivity.tk is like

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}

2

There are 2 best solutions below

7
amit.flutter On

Flutter has a single MainActivity file. if you want to add more screen then please read doc and blogs here is one for you: Add Multiple screen

0
byeo On

See this post regarding multiple Android Activity entiry points using @pragma('vm:entry-point')

https://medium.com/@vad.pinchuk/multiple-entry-android-application-with-flutter-or-alternative-ways-to-restrict-access-to-1260e097ef9f