My First Two Flutter Plugins and Track My Indoor Workout News

Jul 22, 2023

Last time, I talked about how I prepared Track My Indoor Workout for contributions and Google Dev Library and shared thoughts on installing Flutter from Snap. This post is more along the lines of Dart null safety and the Flutter embedding API deprecation. Both of the latter require refactoring and sorting out plugins that lag behind in maintenance.

The latest big changes on the front line are Dart 3.0 and accompanying new Flutter versions, and overlapping with that is the Android Gradle Plugin (AGP) upgrade to version 8.0 and beyond. During the initial Dart null safety rollout, pub.dev/packages badged plugins with whether they supported null safety or not; nowadays, the main badge on a plugin’s front page is about Dart 3 compatibility. The null safety badge is still there under the Versions tab.

Just as with null safety, I ended up attacking the changes head-on and taking a forward-fleeing strategy. I’m already on the Flutter beta channel (Dart 3.1) and iterated through my plugin dependencies. I tried to upgrade to the latest version of everything, switching to a better-maintained fork if available (qr_widget instead of qr_flutter, for example), or eliminating a plugin if possible (easy_folder_picker, bluetooth_enable_fork). But the biggest step was when I decided to carry some plugins on my back and created my own plugins. In the past (and still today), it wasn’t uncommon for me to report bugs and craft PRs to help plugins. Sometimes I cannibalized code if a plugin was UI-only (no platform-specific parts) and, for some reason, maintenance was lagging. I reached new heights and created two plugins:

  1. fab_circular_menu_plus, which was cannibalized source code for a while because a critical error (unclickable menus) was never fixed, even though I debugged it and crafted a PR.
  2. listview_utils_plus, to make it fully Dart 3.1-compliant. It’s somewhat concerning that the original author doesn’t advise using the plugin, but it is a compact, perfect solution if you want to feed a ListView from a backend with many entity rows and want to lazily page it.

Both of these plugins are UI-only, so I didn’t have to deal with platform-dependent sections. I’m happy to claim my first two plugins, even though necessity dictated that I take the leap.

As far as Track My Indoor Workout features go, numerous major changes are coming. The biggest one is replacing the current Floor-based (wrapper over Sqflite) database persistence backend with Isar. I had been eyeing object databases for a long time, such as Hive, Sembast, or ObjectBox, until I heard of Isar at a Flutter meetup and HumpDayQnA. I studied it more, and it won my selection process.

It took a long time to maintain the feature branch in concert with the main development branch. The app uses it in the beta release track; it involves some risky procedures such as a database migration from Floor/Sqflite to Isar the first time the athlete starts the new version of the app. It’s a testament to Isar that the entire migration of about 350 workouts takes less time than importing a CSV workout file with Floor did previously. This means that Isar is truly more than 100 times faster than the old backend. The previous slowness put a burden on overall UI responsiveness, since fitness machines tend to send data multiple times a second. It even posed a challenge for older devices or weak tablets. Isar will greatly help with all of that, even though I haven’t introduced Riverpod yet and am using setState-style UI updates.

As for fitness machine support, I had a mad dash trying to finish support for the Kayak First ergometer so the company could showcase my application at the FIBO Fitness Expo in Köln from April 11-14 2023. The communication protocol for this machine’s console is different from that of any other machine, so I needed to refactor the core logic of my app. I tested the app on Android 6 (ASUS ZenFone), Android 9 (Motorola Moto g6), and Android 12 (OnePlus Nord EU G5) phones. Unfortunately, the manufacturer still has some glitches, so we need to iterate more, but hopefully it’ll be in the bag this year.

I’ll also soon put in time for the Concept2 RowErg. I was in Costa Rica for a week and the hotel gym had not only a C2 RowErg, but also a C2 SkiErg (and even a C2 BikeErg, but that was out of commission). Unfortunately, I didn’t have time to work on adding support. However, I have access to a RowErg here in Fresno (thanks to Raw Fresno), and I’ll complete both the proprietary C2 protocol and FTMS (for the newer consoles).

The Kayak First-induced code refactorings broke support for the Schwinn 170, 270, and 570. About three users reported that, but fortunately, with some help, I was able to restore it through meticulous code review (since I don’t own such machines). It’s hard to provide support for a machine when I don’t have access to it. There are still outstanding support requests for:

With a lot of effort, I’m happy to provide different running, cycling, and swimming tracks for different time zones. This is not per country yet, but at least it should solve problems with time zone misalignment of uploaded workouts. A frequently requested feature is localization; that will be a big undertaking, but it would be so great! I want to be able to tell speed sensors apart from cadence sensors by looking at their appearance data. Flutter Blue Plus doesn’t support that yet, but I provided a PR. Chip Weinberger put so much effort into the plugin that I have to recreate my PR because Protobuf was removed. I’m happy that there’s a very active maintainer.

If you have any feature requests or issue reports, don’t hesitate to file one on GitHub or contact me.

Comments loading...