What SwiftUI Means for Flutter

What SwiftUI Means for Flutter

Flutter is likely to benefit as Apple developers see that they can use the same declarative UI techniques as SwiftUI but also run their code on many more platforms, including Android, Windows, Web, and IOT.

On June 3 at WWDC ’19 Apple made a lot of big announcements, but an important one that didn’t quite make the top news headlines was the release of SwiftUI, a new declarative UI framework for building iOS (and iPadOS/macOS/watchOS/tvOS) apps. Of course, for software developers this was probably the most exciting news of all. After all, how many of us can actually afford the new Mac Pro?

The reason why developers are so excited is that Apple has finally joined the modern era of declarative UI programming. Apple developers had to sit on the sidelines as the likes of React Native and Flutter showed off their ability to drastically improve code simplicity and reduce development times with hot reloading. Apple developers also sighed as Google announced Jetpack Compose, a new declarative UI framework for Android, at I/O ’19. So when Apple made the SwiftUI announcement it was rightly met with collective gasps and cheers in the audience.

What we are witnessing is a continuation of the declarative UI programming revolution that was started by React. Thanks Facebook! That needs to be recognized and applauded. Flutter also deserves credit for getting us to this point. Flutter is one of the top 10 most-starred repos on Github, was recently ranked the #3 most loved framework in the 2019 Stack Overflow developer survey, and is the #1 fastest-growing skill among software engineers by LinkedIn. As an experienced native iOS developer who converted to Flutter 2 years ago and never looked back, I have a vested interest in watching the Flutter community succeed. So how should we interpret the SwiftUI announcement?

What is declarative UI programming anyway?

For those new to the topic, I want to briefly describe what declarative UIprogramming actually is. So, it turns out that writing UI code is arguably the most complicated part of any modern application. Today’s mobile/desktop/web apps have to be responsive, handle device rotation, dynamic font sizes, light/dark mode, different themes, user customizations, role-based permissions, feature-flagging, and A/B testing. Now throw a couple of animations on top of all that. Oh yeah, and make everything delightful. And finish it by yesterday.

Before declarative UI programming, you would typically write your code in the following fashion: Handle the login button. Show the busy spinner. Call the backend. Hide the busy spinner. Redirect to the home screen. Show a popup on failure. In this “imperative” paradigm, you directly change individual parts of your UI in response to various events. Seems simple, but as an app gets more complex, it gets harder to update without things breaking unexpectedly. Things get complicated real fast. It becomes difficult to see the relationship between events and handle edge cases. That’s why sometimes you see apps in bizarre, inconsistent UI’s. It is the result of a combination of states that the developers did not expect.

When imperative UI programming goes wrong.

In contrast, in a “declarative” paradigm, the user interface is “declared” as a function of some data that represents it. That data is called state. As that state changes, the UI updates automatically. So, using the same example above: If no user, show login. If user, show home. If busy, show spinner. If failure, show error. The difference is that all the different states are accounted for in one place, preventing unexpected or inconsistent results. The result is usually:

  • Vastly reduced complexity
  • Fewer lines of code
  • Improved code quality
  • Reduced development times

It’s no wonder that developers love it. So Apple joining the party is kind of a big deal. It validates the declarative paradigm for the whole Apple community.

What does this mean for Flutter?

I love Flutter. It took what React Native started and ran with it. With its native performance, zero dependencies on native platform UI components, and ability to support iOS, Android, Mac, Windows, IOT, and Web, I am convinced that it is the best choice for modern application development. I am also amazed at how it has captured the mindshare of beginners and experienced native mobile developers alike. I do want to see it succeed.

In the immediate term, SwiftUI will probably reduce the incentive for Apple-only developers to adopt Flutter. Developers will be able to receive many of Flutter’s benefits including declarative UI architecture as well as hot reload, which will alleviate the pain of Swift’s famously slow compile times. However, since SwiftUI only works on iOS 13 and up, apps will still have to support the old imperative style for several years before fully transitioning. That means potentially maintaining two entirely separate UI codebases for a long time!

With Flutter, Apple developers will see that they can use the same declarative UI techniques they have already learned, but also run their code on many more platforms.

In the longer term I think that Flutter will ultimately benefit from SwiftUI. Inevitably, the pressure will mount on Apple-only developers to port their apps to other platforms such as Android, Windows, and Web. With Flutter, Apple developers will see that they can use the same declarative UI techniques they have already learned, but also run their code on many more platforms. At that point, Flutter will be there waiting with open arms. Interesting in getting a head start?

Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow us on Facebook | Twitter

Further reading

Learn Flutter & Dart to Build iOS & Android Apps

Flutter & Dart - The Complete Flutter App Development Course

Dart and Flutter: The Complete Developer’s Guide

Flutter - Advanced Course

Flutter Tutorial - Flight List UI Example In Flutter

Flutter Tutorial for Beginners - Full Tutorial

Using Go Library in Flutter

Parsing JSON in Flutter


Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Google's Flutter 1.20 stable announced with new features - Navoki

Google has announced new flutter 1.20 stable with many improvements, and features, enabling flutter for Desktop and Web

What is Flutter and why you should learn it?

Flutter is an open-source UI toolkit for mobile developers, so they can use it to build native-looking Android and iOS applications from the same code base for both platforms. Flutter is also working to make Flutter apps for Web, PWA (progressive Web-App) and Desktop platform (Windows,macOS,Linux).

Complete SQLite CRUD Operations in Flutter

Now a days almost all application have to have some kind of data storage. Application without collaboration with other users will make use of local storage db – SQLite. In this tutorial, we are going to cover all CRUD operations in Flutter with SQLite.

Adobe XD plugin for Flutter with CodePen Tutorial

Recently Adobe XD releases a new version of the plugin that you can use to export designs directly into flutter widgets or screens.

Flutter - How to Add AdMob Real Ads in Flutter App | Flutter AdMob Tutorial

Hello Whats is up Everyone So, Today I am going to show u How to Add Admob Real ads in Flutter apps which are very Easy Implement After watching this video u...