I am currently working on an android project which is ~75% complete. I need a similar application for iOS.
Can I import this project to flutter? How?
Also, will flutter supports the libraries I have used in this project?
Simply put, you can migrate your iOS/Android app into Flutter seamlessly without compromising on performance. Even our team has leveraged this feature to convert an existing application to a Flutter app.
Opening a project from existing source code To open an existing Flutter project: Click File > Open from the main IDE window. Browse to the directory holding your existing Flutter source code files. Click Open.
Launch Android Studio, and click File > New > Import Project. Locate your project directory, click the build. gradle file you created above to select it, and then click OK to import your project.
Add to Android applicationsAuto-build and import the Flutter module by adding a Flutter SDK hook to your Gradle script. Build your Flutter module into a generic Android Archive (AAR) for integration into your own build system and for better Jetifier interoperability with AndroidX.
Flutter applications work completely different, i.e. not like Android nor like iOS. Flutter has its own architecture and therefore own plugins etc.
No, you cannot convert your existing Android code into Dart code for Flutter, which is necessary to enable cross-platform behavior because all code used by the Flutter SDK has to be written in Dart.
However, you could make use of your Android code by just including it in the Android folder and trying to integrate it with the Flutter SDK, which will probably be all lot more work than just rewriting it entirely in Dart. This is also not what you generally want to do because native Android and iOS code make most sense to be used to enable features that you cannot achieve with Flutter, in the form of plugins.
There is also a third approach, which is that you keep your Android code and only add features with Flutter. This is harder to implement because you will have to create an interface to "switch" to Flutter from Android code. Using this you would also need to rewrite your remaining parts for iOS in either Flutter or native iOS, which does not help you at all.
There is a pretty straight forward answer to this.
Flutter is a layer on top of the native SDK's. This means that you could keep your code because, if you ever took a look into a Flutter project, you would see that in it there are, at the moment, essentially three structures you can work with:
lib
folder for Dart code + files Flutter needs to e.g. include plugins, short: Dart code for Flutter
iOS
folder for either Objective-C or Swift code, which also includes the usual iOS accessories
android
folder for either Java or Kotlin (or C++) code and all other gradle files etc.
This means that you can use native code if you want to, but you do not need to do it.
You can completely ignore the android
and ios
folders during development if you want to`.
Most likely you will just be modifying aspects like the app icon, name, version name, license keys etc. in your native code.
Flutter's goal is to write all code in Dart and only in the Flutter SDK, which means that your existing Android code could be included in the project, but it will not have any use for iOS because all cross-platform work is done in Dart making use of the Flutter SDK.
If you really want to switch to the Flutter SDK, your best choice is entirely switching to Flutter, i.e. rewriting all features in Dart.
There is no "import" possibility to "convert" Android code to Flutter code. This would not even work if they were written in the same language because the Flutter architecture is completely different and the way you build apps is not remotely related to Android applications.
If you think that learning Dart and rewriting your application for cross-platform is not worth it but you still want iOS support, I would suggest you to write in iOS native, but my general suggestion for the problem is rewriting the whole application in Dart.
Flutter use a radically different rendering architecture. All the rendering is computed with Dart code, without ever using native elements.
So not only you can't use native code, you can't have something like a "Import native to flutter" either.
For libraries, it's a complicated topic. You can use them. But only inside what Flutter calls Platform channel. Which is an api to make system call written in code that run natively in the OS.
So libraries such as Firebase are fine. But components libraries or things like rxjava are out. You'll need a similar dart library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With