The growth of mobile IoT apps
The IoT (Internet of Things) industry has seen a massive growth in the recent years thanks to the advancements in technology. Industries like healthcare, car manufacturing, smart homes have adopted this new trend of interconnected systems. The shift for everyday devices to become smarter, introduced the necessity of an interface to “communicate” between the human factor and the device itself. What’s the easiest available tool who can do this job? The smartphone!
If you want to develop a mobile application in this new IoT world, you may be wondering, which is the most efficient tool for this job? While there is a no clear winner here, in this article I would like to shed a light on a cross platform solution – Flutter, and why it might be a good solution for your next idea. (If you want to read more about Flutter and cross platform framework advantages, you can read more about it in our previous article).
Using Flutter in the smart-home industry
I remember when Ioana, my current manager, messaged me on Slack and asked for a call to present me an opportunity to work on a new mobile IoT application in the smart home industry. As a mobile software engineer, I was thrilled, being able to experience how software on a smartphone interacts with a physical device so I’ve accepted the challenge right away.
After the initial hype faded away, we started to talk more about the project, so one of my first question was:
Luci: “Okay, so we need two separate applications: one for Android using Kotlin/Java and one for iOS using Swift/Objective-C, right?”.
Ioana: “No, Luci, just one for both operating systems. With Flutter and Dart”
What the Flutter?!
Flutter development limitations
While I have always been a Flutter enthusiast, I had my own initial doubts. Until then, my mind was settled on cross platform solutions being a great choice only for building “web-like” apps for mobile devices.
Mobile IoT applications requires more than a communication with a backend server. It usually includes Bluetooth/Wi-Fi functionality, which often results in more operations such as scanning, connecting, reading/writing data to a physical device.
The project required a mobile application which would communicate via Bluetooth with a physical device. Each operating system has its own way of accessing Bluetooth functionality, so my question was: is Flutter going to be a reliable, performant and easy solution for developing such an app?
Developing Bluetooth functionalities using Flutter
Before starting the project, I’ve researched more about the possibilities of utilizing a plugin to solve our issues.
For a bit of context, a plugin is a special package that exposes native functionalities (written with platform specific code) to be easily accessible by Flutter framework.
Knowing that Flutter is heavily supported by open-source community, I was pleased to find that there was an impressive number of plugins that solved the Bluetooth issue.
Later, we learnt that this project already had a native solution in place for specific Bluetooth functionalities with the bridge already created in Flutter. Our task was to extend the Bluetooth component, tailored to our application’s needs.
Because of Flutter’s great documentation, the process went smoothly, and in no time, we had all the functionalities that we needed, and we could focus on other parts of the project.
The benefits of building IoT mobile applications with Flutter
As you can see, not all the time one can go with a plugin and solve all the issues. Sometimes native code is still required, so you may be wondering, why not go with a native solution in the first place? To answer this question, we need to look at the bigger picture.
For that, let’s consider an example, a mobile application that uses Bluetooth to connect and read/write data to a device. Let’s consider that we want a custom solution for Bluetooth functionality, and we opt to write native code for that part.
From an architectural point of view (warning – this is extremely simplified), we can divide the application in the presentation layer – the user interface (UI) and the data layer – the Bluetooth communication.
As we can see, the UI between apps is shared and the data logic is split into Android and iOS implementations. While we can already see a benefit by building the user interface only once, the diagram above is not 100% accurate.
We considered only the communication part, but when it comes to mobile IoT applications, there is more than a connecting to a device and reading data. You would usually analyze that data, present some diagrams, alert the user with notifications, store it locally or it in the cloud and the list can go on. Having said that, a diagram closer to reality would look like this:
Bonus number 1: writing platform specific code is well documented by the Flutter team and a developer who is familiar with Dart will easily pick up languages such as Kotlin for Android and Swift for iOS. Most of the time, there is no need for in depth knowledge of the whole underlying operating system. (But of course, that can help)
Bonus number 2: creating beautiful and complex UIs in Flutter is a fast and enjoyable developer experience while also maintaining great performance.
So, should you choose Flutter for mobile IoT apps?
There are a lot of great choices for developing mobile applications and is hard to pick the number 1 solution as each project idea is different. But, if you want a mobile application with reduced costs, easy maintenance and with no sacrifices on user experience and performance, Flutter is the right solution for you, even for more demanding applications like the ones in the IoT domain.