Тёмный

Designing with Types in Dart & Flutter - Sum Types Tutorial 

Reso Coder
Подписаться 113 тыс.
Просмотров 7 тыс.
50% 1

Опубликовано:

 

29 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 24   
@PsykologpraksisFyn
@PsykologpraksisFyn 5 лет назад
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.
@mikemannox4191
@mikemannox4191 4 года назад
I don't like this, too much hidden code, you should be able to see your definitions.
@mikemannox4191
@mikemannox4191 4 года назад
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
@yos2413
@yos2413 Год назад
@@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
@mikemannox4191
@mikemannox4191 Год назад
@@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 😥
@RaymondAtivie
@RaymondAtivie 5 лет назад
What extension do you use in your pubspec.yaml to see what each dependencies satisfy?
@thomasmabika7291
@thomasmabika7291 5 лет назад
another great video! Could you do a series on other architectures like MVC, MVP, MVVM etc? would be great to see their implementation.
@deriegle
@deriegle 5 лет назад
Thanks for this video! I would love to see enums with custom values to be added to Dart. I feel like it could help solve some of these problems.
@mikemannox4191
@mikemannox4191 4 года назад
They are coming, seems libraries like Sealed Unions are a very popular replacement for now
@yos2413
@yos2413 Год назад
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.
@obeydadjeffal4442
@obeydadjeffal4442 5 лет назад
Nice Tutorial, a quick note: in 33:20, I think the protected members are not accessible, it's just the getters (lines 119-120)
@christianonwe2045
@christianonwe2045 5 лет назад
Wow nice. Love this. Thanks
@1wisestein
@1wisestein 3 года назад
@ResoCoder ! Are you Canadian?
@ResoCoder
@ResoCoder 3 года назад
Nope! I'm Slovak.
@aytunch
@aytunch 5 лет назад
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;)
@karol-lisiewicz
@karol-lisiewicz 5 лет назад
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.
@mikemannox4191
@mikemannox4191 4 года назад
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 .
@BelgianDaSeeD
@BelgianDaSeeD 5 лет назад
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.
@ResoCoder
@ResoCoder 5 лет назад
Thanks! I'm using the Fira Code font with ligatures enabled in VS Code settings.
@BelgianDaSeeD
@BelgianDaSeeD 5 лет назад
@@ResoCoder: Cool, thanks for your answer !
@mikemannox4191
@mikemannox4191 4 года назад
That is handled by enabling font ligatures and choosing a compatible font - like Fira Code github.com/tonsky/FiraCode/wiki/VS-Code-Instructions
@AnorNeto
@AnorNeto 5 лет назад
How do you show the macros on a class? like the one you clicked to create the toString template?
@mikemannox4191
@mikemannox4191 4 года назад
marketplace.visualstudio.com/items?itemName=BendixMa.dart-data-class-generator
@AnorNeto
@AnorNeto 4 года назад
@@mikemannox4191 thanks!!
Далее
无意间发现了老公的小金库 #一键入戏
00:20
Voy shetga man aralashay | Million jamoasi
00:56
Просмотров 248 тыс.
Algebraic Data Types (ADT) in Scala | Rock the JVM
14:19
Clean and Organized Code with Linting
9:41
Просмотров 10 тыс.
Freezed ❄ - Data Class & Union in One Dart Package
36:28
Bringing pattern matching to Dart
20:28
Просмотров 39 тыс.
Svelte 5's Secret Weapon: Classes + Context
18:14
Просмотров 24 тыс.
Dart 3 Class Modifiers Is kinda Confusing
5:48
Просмотров 9 тыс.
无意间发现了老公的小金库 #一键入戏
00:20