My first Flutter project as an long time Angular developer
Tags: flutter, angular
Published: 2022-09-20 08:32:09

I am a full stack software engineer with 10 years of experience with .Net (Core) and Angular (I have started with AngularJS).

We, at [Novaloop](https://www.novaloop.ch/en) needed an MVP (or rather a working prototype) and we decided to implement it in Flutter.  We chose Flutter mainly because we wanted to be quick and we wanted the MVP to potentially run on all different platforms.

## The search for a new community

As a long time user of the .Net Framework and Angular, I am very familiar with influential people in the community that create good content. This is definitely not the case for Flutter. 

It's not easy coming from the outside into a new community and catching up for several years. 

There is a very active Discord channel (https://discord.com/invite/N7Yshp4) and also a lot going on in the Subreddit (https://www.reddit.com/r/FlutterDev/). Many developers are also very active on Twitter. 

I have put together a Twitter list: https://twitter.com/i/lists/1540588470950846466

And here are a few selected Twitter accounts.

### Twitter Community

Hint: The Flutter community handles use the blue heart emoji extensively ;)

No particular order:

| Twitter Handle | Description |
| --- | --- |
| [@RydMike](https://twitter.com/RydMike) | Learn a lot about theming |
| [@vandadnp](https://twitter.com/vandadnp) | Flutter courses on YouTube |
| [@RobertBrunhage](https://twitter.com/RobertBrunhage) | Great Flutter courses |
| [@felangelov](https://twitter.com/felangelov) | Author of the Bloc library |
| [@vgventures](https://twitter.com/vgventures) | Maintainer of the Bloc library |
| [@remi_rousselet](https://twitter.com/remi_rousselet) | Author of Provider and Riverpod |
| [@biz84](https://twitter.com/biz84) | Great Flutter courses |
| [@ThomasBurkhartB](https://twitter.com/ThomasBurkhartB) | Author of get_it dependency injection |
| [@mhadaily](https://twitter.com/mhadaily) | Community leader and organizer |
| [@verry_codes](https://twitter.com/verry_codes) | Flutterista and community leader Flutter DACH |
| [@letsgetwckd](https://twitter.com/letsgetwckd) | Great Flutter courses (flutterly) |
| [@resocoder](https://twitter.com/resocoder) | Great flutter courses |
| [@devangelslondon](https://twitter.com/devangelslondon) | Community leader |
| [@ASalvadorini](https://twitter.com/ASalvadorini) | Flutter speaker |
| [@roaakdm](https://twitter.com/roaakdm) | Flutterista and Flutter Vikings speaker |
| [@CFDevelop](https://twitter.com/CFDevelop) | Flutter Dev |
| [@luke_pighetti](https://twitter.com/luke_pighetti) | Flutter GDE (Genuinely Disturbed Engineer) |

### Learning Resources

Of course, and everyone will say this, the best resource is the official site and the respective documentation of the packages.

But on my way to the first Flutter project, the following materials helped me a lot.

| Description | URL |
| --- | --- |
| Flutter documentation | https://docs.flutter.dev |
| Decoding Flutter | https://www.youtube.com/playlist?list=PLjxrf2q8roU1fRV40Ec8200rX6OuQkmnl |
| Flutter widget of the week | https://www.youtube.com/playlist?list=PLjxrf2q8roU23XGwz3Km7sQZFTdB996iG |
| The Boring Show | https://www.youtube.com/playlist?list=PLjxrf2q8roU3ahJVrSgAnPjzkpGmL9Czl | 
| Code with Andrea, very comprehensive Flutter courses | https://codewithandrea.com/ | 
| Flutter Community @ Reddit | https://www.reddit.com/r/FlutterDev/ |
| Flutter Community @ Youtube |  https://www.youtube.com/c/FlutterCommunityVideos |
| Flutter @ Youtube | https://www.youtube.com/c/flutterdev |
| Flutterfly @ Youtube | https://www.youtube.com/c/Flutterly |
| Majid Hajian @ Youtube | https://www.youtube.com/c/mhadaily |
| Reso Coder @ Youtube | https://www.youtube.com/c/ResoCoder |
| Vandad Nahavandipoor @ Youtube |  https://www.youtube.com/c/VandadNP |
| Robert Brunhage @ Youtube | https://www.youtube.com/c/RobertBrunhage |
| Robert Brunhage Courses | https://robertbrunhage.com/ |
| FilledStacks @ Youtube | https://www.youtube.com/c/FilledStacks/featured |

And following Udemy courses I bought and watched individual chapters when needed during the development.

| Description | URL |
| --- | --- |
| Dart & Flutter - Zero to Mastery [2022] + Clean Architecture (German) | https://www.udemy.com/course/dart-flutter-leicht-gemacht/ |
| Flutter & Dart - The Complete Guide [2022 Edition] | https://www.udemy.com/course/learn-flutter-dart-to-build-ios-android-apps/ |
| The Complete 2021 Flutter Development Bootcamp with Dart | https://www.udemy.com/course/flutter-bootcamp-with-dart/ |
| Flutter - Intermediate | https://www.udemy.com/course/flutter-intermediate/ |
| Dart and Flutter: The Complete Developer's Guide | https://www.udemy.com/course/dart-and-flutter-the-complete-developers-guide/ |

## First steps

### Dart

Coming from C# and Typescript, Dart wasn't too much of a hurdle. Long story short: I learned to love Dart.

Sure, compared to Typescript, certain tasks are more tedious, e.g. parsing JSON responses to objects. But the static analysis over the project works very well and is worth its weight in gold ;)

### Everything is a Widget

At the beginning it takes a bit of getting used to, but with time it actually becomes very natural. 

Flutter's declarative widget system has allowed us to quickly and easily implement specifications from UX designers. At a pace that I have never seen before.

### Architecture and Code Organization

As with many things, Flutter is not very opiniated. It is up to the team to choose the appropriate architecture and also to determine the appropriate solution for the organization of the code. 

Feature-first, layer-first - your choice

## Configuration

I'm used to the framework already bringing solutions and making it easy for a developer to ship different environments. To my knowledge, there is no official solution. 

Andrea has published a good article with a suggestion: https://codewithandrea.com/articles/flutter-api-keys-dart-define-env-files/

## Hot Topics

### State Management

https://docs.flutter.dev/development/data-and-backend/state-mgmt/options

Periodically, Mike Rydstrom (https://twitter.com/RydMik) publishes an overview of the State Management Solutions with the most LIKEs. https://twitter.com/RydMike/status/1528827017172504579

This is the hottest topic in the community. Hardly anyone doesn't have an opinion on it. As far as I understand, there is no official recommendation from Google. There is a discussion about whether there was once an official endorsement for Flutter BLoC. At IO '18, it seems that the BLoC architecture was presented and the package was then developed according to this architecture design. At the moment there seems to be a big momentum for Provider and for the next generation of it: Riverpod. These are maintained by Remi Rousselet (https://twitter.com/remi_rousselet). Soon there will be a new major release (2.0) of Riverpod and there seems to be a lot of changes and simplifications coming our way in the next few months. See also the talk of Remi at the Flutter Vikings conference https://youtu.be/C2Zp731g8Es?t=12762 

The courses of Andrea Bizzotto are great when it comes to Riverpod and a possible architecture. Andrea proposes an architecture and calls it Riverpod Architecture https://codewithandrea.com/articles/flutter-app-architecture-riverpod-introduction/

To get a feel for both architectures, we developed our project with both state management solutions. To be fair, the first version was implemented with Riverpod and the second version with BLoC, so we had already learned a lot during the implementation of the second version. I know NgRx very well from Angular and therefore felt very quickly at home with the BLoC pattern. We also want to store a part of the state in local memory and reload it on restart. We have implemented this with Riverpod itself in the BLoC package there is already a solution `hydrated_bloc`. Also the possibility of global observers has helped us a lot in the development and has helped a bit over the lack of Redux tools (in the browser).

Detailed overview by [@illiaromanenko](https://twitter.com/illiaromanenko): https://github.com/illia-romanenko/flutter_state_management_investigation/blob/main/readme.md

### GetX

This seems to be the red rag in the community. In the world of Harry Potter, it would be compared to Voldemort. In the popularity rankings it is high up, if not on the first place when it comes to state management and dependency injection. But as far as I understand it is considered by the community as its own framework and not as an extension for Flutter. It uses completely different approaches and thus hides much of the Flutter DNA.

### Dependency Injection

As a .NET and Angular developer, I am very familiar with Dependency Injection and use it extensively. So I was rather surprised that there is no solution in the framework out of the box. Again, there are many options and packages. Some even do without Dependency Injection and use singletons or instantiate classes directly. But `new is glue` and it makes it difficult to write tests.

Riverpod already brings a lot with Provider. For the rest and for BLoC we relied on `get_it` from Thomas Burkhart (https://twitter.com/ThomasBurkhartB).

### Router

Not so long ago Flutter released a new Navigator 2.0. It offers a new declarative API and was received controversially by the community. It is said to be very complicated and hard to learn. (As far as I know you can use Navigator 1.0 together with Navigator 2.0).

There are several packages that aim to make the usage of the new Navigator 2.0 easier. We have decided on using the `go_router` package. There was a new major release just a few days ago: https://pub.dev/packages/go_router

We were missing the guard functionality of the Angular router. As a hint: most of the guard logic can be implemented in the `redirect` block of the `go_router`. 

## Flutter on the Web

What finally moved us to work with Flutter was the possibility to publish for the web as well. Unfortunately, the implementation is quite "unconventional". Unlike Angular or React, Flutter does not produce HTML and CSS, but uses the canvas. There are two different rendering options with their advantages and disadvantages.

Some background articles on this:

* https://docs.flutter.dev/development/platform-integration/web/renderers
* https://wilsonwilson.dev/articles/flutter-web-renderers
* https://medium.com/flutter/hummingbird-building-flutter-for-the-web-e687c2a023a8
* https://medium.com/flutter/flutter-web-support-updates-8b14bfe6a908
* https://medium.com/@GSYTech/how-to-optimize-flutter-web-and-how-flutter-web-work-in-html-renderer-b399ffd66718

### Testing Flutter Web Apps

This is what I missed the most from Angular. I am a big one of integration testing in the frontend. For this I prefer to use Cypress. Cypress is unfortunately not usable with Flutter, resp. only via detours and by far not as comfortable as Angular.
With the `integration_test` package similar results can be achieved and hot reload seems to be possible. Unfortunately I failed there. For the current project we have also set the `BLoC` package and for a certain part of the state we need the `hydrated_bloc` package. Unfortunately at the moment it seems that no integration tests can be realized: https://github.com/flutter/flutter/issues/96939

## Conclusion

The next comments are strictly my personal opinion and refer only to the web version and not to the mobile development part of Flutter.

I love Flutter's declarative widget system. The speed at which prototypes and executable MVPs can be developed, for all platforms, is impressive. 

I would not, as of today, implement a complex and long-lived web application with Flutter. For an executable prototype or a small MVP to test the market, Flutter is great.