Designing with Types in Dart & Flutter - Sum Types Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ก.พ. 2025

ความคิดเห็น • 24

  • @PsykologpraksisFyn
    @PsykologpraksisFyn 5 ปีที่แล้ว +7

    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 5 ปีที่แล้ว +1

      I don't like this, too much hidden code, you should be able to see your definitions.

    • @mikemannox4191
      @mikemannox4191 5 ปีที่แล้ว +1

      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 ปีที่แล้ว +5

    What extension do you use in your pubspec.yaml to see what each dependencies satisfy?

  • @thomasmabika7291
    @thomasmabika7291 5 ปีที่แล้ว +2

    another great video!
    Could you do a series on other architectures like MVC, MVP, MVVM etc? would be great to see their implementation.

  • @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)

  • @deriegle
    @deriegle 5 ปีที่แล้ว +1

    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 5 ปีที่แล้ว

      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.

  • @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 ปีที่แล้ว +1

      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 5 ปีที่แล้ว

      That is handled by enabling font ligatures and choosing a compatible font - like Fira Code
      github.com/tonsky/FiraCode/wiki/VS-Code-Instructions

  • @christianonwe2045
    @christianonwe2045 5 ปีที่แล้ว

    Wow nice. Love this. Thanks

  • @1wisestein
    @1wisestein 4 ปีที่แล้ว

    @ResoCoder ! Are you Canadian?

    • @ResoCoder
      @ResoCoder  4 ปีที่แล้ว

      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 ปีที่แล้ว +3

      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 5 ปีที่แล้ว +1

      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 .

  • @AnorNeto
    @AnorNeto 5 ปีที่แล้ว

    How do you show the macros on a class? like the one you clicked to create the toString template?

    • @mikemannox4191
      @mikemannox4191 5 ปีที่แล้ว +1

      marketplace.visualstudio.com/items?itemName=BendixMa.dart-data-class-generator

    • @AnorNeto
      @AnorNeto 5 ปีที่แล้ว

      @@mikemannox4191 thanks!!