Developing a Native Mobile App ft. Flutter

Amorn Apichattanakul
KBTG Life
Published in
4 min readApr 24, 2021

Flutter is cross-platform mobile development. Write only once and you can deploy it to both iOS and Android. Yet, some native mobile developers refuse to learn Flutter simply because it’s not native. That’s the number one reason that always comes up whenever I ask if they would give Flutter a try. I don’t blame them though, I was once just like them. “I’m an iOS developer, why do I have to write Flutter?” However, after spending some time with Flutter thanks to work assignments, I fell in love with it — not for the language nor framework, but for the ability to control both business logic and UI in one single source of truth. Even with a small team, you can make a big product. In terms of performance and language, Flutter is amazing. The performance is about 85–90% to native. That being said, I still love Swift for their Enum and Protocol extension.

The reason why I’m explaining all of this is to convince you to try Flutter. It’s fun and you’ll be open to other languages that will help improve your own work. Alas, some native mobile developers might still be hesitant, saying that their work requires Native and they’ve been writing it for years. It’s too late to use Flutter for their current project.

“Maybe next project, I’ll give it a try.”

You know what? There’s no need to wait because you can do it right now with your current native project! Flutter has a cool feature called Add to App. Here’s a nice tutorial from Flutter team.

Basically, we can add the Flutter app as a plugin in your Native app, so you can start writing Flutter and continue your project. This way, you’ll get to learn Flutter and continue working as a Native at the same time. Case closed.

In theory, you have two options to write Flutter as a plugin for your native:

  1. You install Flutter in your machine. In fact, everyone on your team needs to install and import Flutter into your project. The benefit of this is you can use Hot Reload, a cool feature in Flutter to test your app in real-time, so there’s no need to compile and rebuild the app. It seems like a nice solution but I think it’s suitable for a smaller team where everybody has time to learn Flutter.
  2. You don’t need to install Flutter. Instead, you can import Flutter as a module using CocoaPods, which is similar to external libs. Unlike the previous one, only the people that develop modules need to install Flutter for development. Other team members can just import your Flutter module and use it as a lib. I see this method more suitable for a large team where the native developers can focus on the core app, while the Flutter team can focus on add-on and some business logic part to share in both platforms.

Native and Flutter can send information back and forth easily via Flutter method channel, which is similar to having one class and sending data to it. You can follow the tutorial to create a Flutter method channel. I guarantee that you’ll spend 15 minutes at most and everything will work like a charm.

https://flutter.dev/docs/development/platform-integration/platform-channels

Here's a tutorial on how to send data back and forth between Native and Flutter.

You can follow this demo by Flutter team from the link below. They‘ll show you how to implement Flutter’s add to app into the native. It takes around 30 minutes to make it work for each platform.

Now let me show you some samples in iOS. Here’s AppDelegate.swift. Simple, right? All you require are three more lines.

And here’s your ViewController.

Hit the button and it will show another page made from Flutter! Once you got all set up correctly, you can start working on your product with Flutter and zero worries. That’s pretty much it! No more excuses, time for you to try Flutter. 😽

Want to read more stories like this? Or catch up with the latest trends in the technology world? Be sure to check out our website for more at www.kbtg.tech

--

--

Amorn Apichattanakul
KBTG Life

Google Developer Expert for Flutter & Dart | Senior Flutter/iOS Software Engineer @ KBTG