I really need a base development platform to transform my ideas into apps. This is not necessarily to earn money, but in order to quickly convert the idea into a demonstration, a prototype or for fun. Modern smart phones have decent processing abilities, storage capacity, are jam-packed with different sensors and have the posibillity to communicate through wifi and bluetooth. If I just got comfortable and found a development platform and language that would be my go-to for everything I wanted to try out, both for private and professional use, I would be willing to give it a chance.
A long time ago, I think it was back in about 2009, I got inspired after reading “The 4-hour workweek” by Tim Ferriss. I was interested in resistance training, just got my iPhone 3G and thought “How can I improve on my and other peoples resistance training based on the currrent cutting edge training knowledge?”. I was very much inspired by the approach by @chadwaterbury, who was into training for mechanical power and the central nervous system. I decided to make “IronChart” – an app that would measure force, power and work while doing resistance training with machines or weights.
IronChart was put to life by learning objective-C and programming in XCode for iOS. I still think training for power or work is a good idea, but the stupid thing about the IronChart-app and the setup was that you had to attach the iPhone to the bar or the machine weight through an iPhone cover with a magnet. This would look really silly in the gym and required selling a separate item, the magnet cover.
I found programming Objective-C to be an OK experience, especially with XCode being such a good IDE with integrated tools for GUI design, static analyzer etc. What I found really protectionist by Apple was that it was impossible to program for iOS without having a computer running MacOS, a requirement that is still valid today. I ended up creating Hackintosh-computers, running virtual machines and buying a used MacBook. The MacBook broke down a few months after I bought it. All programming was done while my kids were really small – Not a good experience for family life!
IronChart never got any traction and I ended up discontinuing the project after a few years. I never got to build a tribe around the app and new iPhones started to appear on the market. I said to myself that I will never put so much effort into something that ends up being scratched in the end.
I later aquired two Android phones after feeling that Apple and iPhones were not innovative any more. The main and official course for learning Android development was at Udacity. At the time of taking the course I felt that the course was allready outdated and the community could not decide whether to code in java or the google backed language Kotlin. I felt that developing with Kotlin under Android Studio was very hard (it sucked). You could off course repeat what was being taught at the course, but I never acquired the skills to use it as a creative tool for my ideas. I was trying to create an app using the camera, but the camera2 examples were riddled with errors and the cameraX jetpack was limited for my use.
New ideas appeared and I though why not start from scratch and find the best language for cross-platform development. The first though was Xamarin from Microsoft, but that seemed to have a shrinking community of developers. I finally decided to take a second look at Flutter, as it seems to be the currently most popular cross-platform development framework:
The reason why I said “second look” was that I had a peek at Flutter previously, but always thought of it like an framework that you could make good looking apps, but without much functionality and without any possibility to connect to in-built sensors.
After looking closer at Flutter I found that the framework is so much better than I thought:
- Flutter is made by a team from Google and it appears that Google is focusing more of their attention to Flutter than native Android development through Kotlin or Java.
- Flutter is open source and makes it possible (and actually quite easy) to build upon/adapt original code by just ctrl-clicking into source-files you want to learn more about.
- A lot of readily available (and open source) libraries are available at pub.dev. These cover a broad range of topics since Flutter has become so popular. It appears to be more easy to implement code for hardware on iOS and Android devices in Flutter than it is to do it in Swift for iOS or Kotlin for Android. Just add “camera: ^0.9.4+7” to the pubspec.yaml file, press save and you have included the necessary library to use camera functionality 🙂
- Compiling native code for both Android and iOS has always been a game of patience. It just takes forever to compile and build and on the halfway you discover bugs and errors. Flutter is literally starting from a blank canvas, painting all widgets it uses onto a blank screen (In Flutter most everything is a widget). It is doing this in a just in time fashion. This results in a gem when compiling: “Hot reload” will keep the current running app up and running and just replace the code that is updated on the fly. So rather than stop the app running/debugging, change the code, recompile and build, you just hit the “Hot reload” button and the changes done will reflect to the screen in the blink of an eye.
- Documentation is fantastic: Weekly videos are shared by the team on YouTube, code snippets (cookbooks) show the essentials, tutorials and understandable documentation are available for every widget imaginable.
- Flutter is the GUI part of the framework. Dart is the real development language under the hood. My initial though was that I needed to learn yet another programming language, but Dart feels very familiar and similar to programming in c/c++, at least from my point of view. You can easily setup code-skeletons in VS Code (with external libraries) or at DartPad if you want to try out some Dart functionality without making a full Flutter app.
- Building GUIs is very different from drag-and-drop IDEs like Android Studio and XCode: The Flutter GUI is built up by populating a widget tree with different widgets for buttons, text, lists, padding, containers etc. This can seem a bit overwhelming at first, but through Flutter DevTools that can be used in both VS Code and Android Studio and the instant updates you get on the real device, building GUIs has never felt more enjoyable. I would though admit that a hybrid tool for creating the first GUI layout would have been a great addition to the toolset.
I wanted to get up and running quickly: I started by watching a couple of YouTube videos for the basics. I then decided to buy “The Complete 2021 Flutter Development Bootcamp with Dart” from The App Brewery (you save some money by buying directly). The decision was mainly made based on Angelas nice voice and clear instructions. Unfortunately the course was a bit outdated and some of the code needed to be rewritten, something that was ok with a good community.
After the course I have mainly struggled with three things:
- Null safety was introduced in Flutter 2.0. This bit was not covered in the course material, but it is quite manageble after watching a few Youtube tuts. By using null safety you avoid a lot of crashes that would have happened in the past, but it makes coding a bit more cumbersome.
- State Management – Storing states, handling events and notifications is collectively called “State Management”. Local state handling (ephemeral state) is easy by using stateful widgets and calling “setState”. When working globally/at app state/shared state state management becomes more cumbersome. The old way used lifting states up through the widget hierarchy, which was difficult and wasteful. The Flutter team now recommends using the Provider package for state handling. I tried this approach, liked it, but got hooked on a different methodology described as “Flutter State Management for Minimalists”. Without going into detail I find this approach perfect for me.
- Asynchronous programming – If you want data that is not immediately available, you need techniques to not block the cpu from processing other code while waiting for the data. Such data in dart are called Futures (single data) and Streams (multiple data). I am still learning how to create, manipulate and use such data, but I have learnt some basic techniques of adding the words “async” and “await” to functions using Futures. Streams can be handled by using the “StreamBuilder” class.
So to summarize: I set out to find a new development framework that I would feel comfortable to use to quickly convert my ideas into apps. At the moment I am still learning to use Flutter, but compared to previous experiences I would say I never felt as comfortable as I am now that Flutter (and dart) will be my preferred overall development tool in years to come.