Longtime iOS Dev – First Flutter App

I’ve been developing mobile applications since 2001, with a focus on iOS beginning in 2008. With all the technologies I’ve seen come and go, Google’s Flutter framework stands out in the crowd. The development cycle is second to none, the APIs are well thought-out and documented and the application performance is exceptional.

I’d like to walk you through my first Flutter application. This isn’t a tutorial on how to build a Flutter app, it’s an opportunity to show you how quickly you can ramp up with Flutter and build an app that covers a fair amount ground.

A Couple Things to Keep in Mind

▪ Up until a few weeks ago, I was new to Flutter, Dart and Firebase (a backend datastore).
▪ Although it took me about two weeks to learn enough about Flutter to write this app, my guess is that an experienced Flutter dev could build a similar app in about a day.
▪ The entire application is about 1200 lines of code, including comments. The same code base for this app (with no changes) runs as a native app on iOS and Android.

Application Features:

▪ Support multiple users.
▪ Create authenticated user accounts on a remote server.
▪ When logged in, view stats for stocks you’ve selected.
▪ Add/delete stocks.
▪ Keep the backend and mobile application data synced.
▪ Support offline mode.
▪ Call remote APIs.
▪ Serialize and deserialize JSON.

Here’s a screenshot of the app:

The source code is available on GitHub.

Flutter Newsletter

Without the help from the supportive community of Flutter developers, there is no way I could have ramped up so quickly. I’ve created a newsletter as a means to contribute to this same community by curating links to content that I think other devs will find helpful. If you are interested, please have a look at The Flutter Report.

Video Walkthrough – iOS Dev’s First Flutter App

I’d like to acknowledge Andrea Bizzotto for his excellent video series on Flutter. His examples were the starting point for the authentication code as well as the login screen. Thanks Andrea, keep up the good work.

Xcode 10 beta 3 – Build Error Workaround

When attempting to build an existing project with Xcode 10 beta 3 I received the following errors:

1) Target 'TestApp' has create directory command with output
2) That command depends on command in Target 'TestApp': script phase “[CP] Copy Pods Resources”

Although not a long term solution, this may get you over the hurdle:

From the File menu:
– Choose Workspace Settings
– From the Build System option, choose Legacy Build System

Build System

Rebuild and you should be good to go – until you have time to track down the culprit.

Protocol Oriented Programming is Not Always the Answer

In Swift, protocol-oriented programming is in fashion. There’s a lot of Swift code out there that’s “protocol-oriented”, some open-source libraries even state it as a feature. I think protocols are heavily overused in Swift, and oftentimes the problem at hand can be solved in a much simpler way. In short: don’t be dogmatic about using (or avoiding) protocols.

Chris Eidhof references the WWDC 2015 talk Protocol-Oriented Programming in Swift as an example of a problem solved using protocols, and at the same time how we lose flexibility and add complexity.

Protocol oriented programming certainly has it place, yet…

let the problem drive the solution, not the other way around.

Protocol Oriented Programming is Not a Silver Bullet ~ @chriseidhof

Error Handling in Swift

Topics covered include the Swift ErrorProtocol; coding with result types; throwing, propagating and handling errors; and a brief look at error handling and asynchronous operations.

This tutorial is a great starting point if you are new to coding in Swift.

Error Handling in Swift : @abargh

Stateful Loops and Swift Sequence Functions

Given the question:

“I’ve come across a situation a number of times where I write code that has to try something one or more times using a `repeat…while` loop and the condition relies upon variables that should be declared within the scope of the loop.”

@ericasadun shows two examples using Swift sequence functions. To complete the discussion, Erica writes a function that:

“…creates a stateful repeat-while loop, which is more or less what I believe the writer was aiming for. It uses a Boolean test, hides the use of sequence(state:next:), and allows a trailing closure for the body of the loop.”

Stateful loops and using Swift sequence functions.