Please notice. There is a breaking change in the newest sum_type package, so you should use version ^0.1.5+1 - as in the video. Very nice video, by the way.
I mean look how clear and easy this is with Sealed Unions! Remove Sum Types from this github.com/ResoCoder/designing-with-sum-types/blob/master/lib/my_types.dart and try it replace it with: // Import the Sealed Union package import 'package:sealed_unions/sealed_unions.dart'; class StateOrProvince extends Union2Impl { static final Doublet _factory = const Doublet(); StateOrProvince._(Union2 union) : super(union); factory StateOrProvince.usState(UsState state) => StateOrProvince._(_factory.first(state)); factory StateOrProvince.caProvince(CaProvince province) => StateOrProvince._(_factory.second(province)); @override String toString() => join( (state) => '$state', (province) => '$province', ); } Hey presto, real Domain modelling, and no generation required, everything is clean and concise - the way it should be
@@mikemannox4191 I agree, dart contained bad design decisions. Good thing is they listened and dart 3 introduces game changing features which takes us one step further into not using code generation
@@yos2413 Unfortunately, they were far too slow with introducing this language feature. For me it is too little, too late. I now look towards Kotlin Multiplatform Mobile as a very serious toolkit for development. For me at least Flutter's time at the top is over 😥
Check out dart 3 which solves most of this issues natively with exhaustive switching. Dart 3 introduces great features such as records, pattern matching, and the sealed class modifier.
Matej thanks for this perfect tutorial. quick question: I know you have been using bloc in the past but have you changed to provider lately? I am working on an complex app which is connected to Firebase firestore. Should I use bloc or provider for that case? thanks man;)
Use whichever you like, you can achieve the same results with both BLoC as well as Provider. At the end, mobile architecture is all about transforming user actions into view states in a separate, testable coponent.
You can use Provider to create and access Dependencies, you then pass those into the BLoC constructor. The BLoC should co-ordinate input streams into Interactors (to perform your requests || logic) then reduce the response and add the output to the output-stream .
Love your videos, they are always clear and interesting. I'm also interested to know which extension you use for your code to visually change when you enter != for example.