How to Merge a Flutter Project in Native Android Project
Posted By : Lucky Mehndiratta | 09-Jan-2020
Flutter provides a comprehensive platform to develop feature-rich mobile application for Android and iOS platforms. By availing Flutter development services, organizations can build mobile applications from scratch or integrate Flutter modules in the existing native projects. After integration, we can develop the remaining part of the application in Flutter and this remaining part will automatically reflect in existing native projects.
Steps to Integrate Flutter project in native Android project
1 Open Android Studio
2 Select Start a new Android Project
3 Select Empty Activity & Press Next
4 Set the Project name, location, language(Java/Kotlin) & minimum API level, then press Finish
5 Now Screen look like the this
6 Run the Android Project by click on the run
7 Now close android studio and start again Android Studio, this time select the New Flutter Project & Select Flutter Module
8 Set Project Name, Flutter SDK path, Project Location
9 Press Next and Finish
10 Run the Flutter Project
11 Now open native Android project(Step 1 to 6) and right click on the project name -> New -> Module
12 Select Import Flutter Module & presss Next
13 Select the Flutter Module path & Press Finish
14 Now Project Structure look like this(Left Side)
15 Now Create a button in android activity_main.xml file and listener in MainActivity.java File
16 We use this Button to start our Flutter Module you can change this as per your requirement
17 Add the following line in AndroidManifest.xml File
<activity android:name="io.flutter.embedding.android.FlutterActivity" />
18 Add the following lines in Button Listener
startActivity( FlutterActivity .withNewEngine() .initialRoute("/my_route") .build(MainActivity.this) );
19 Run the Android Project and click on Open Flutter Project Button.
20 Now Flutter project successfully integrates in the native Android project.
Note: Please attach Flutter SDK to Android Studio if you want to do this.
Explore our mobile app develpment services to accelerate your mobile app development project and reduce time-to-market.
He worked on swift language, UI Design, Api. He is quick in his work and performs at his best.