A Flutter beginners’ learning notes 1

Brewing with a Chemex probably seems like a complicated, time-consuming ordeal, but once you get used to the process, it becomes a soothing ritual that's worth the effort every time.


The very good basic and advance Flutter project tutorial.

FF&DDD architecture knowledge graph

  • DDD architectural layers: 1-Presentation, 2-Controller, 3-Domain, 4-Repository
  • DDD core concept: Domain, Value Object,
  • Type-safe field definition, using class instead of basic type

    • instantiation validation
    • factory constructor
    • private constructor
    • no exception throwing, all caught at repository layer
    • wrap a failure message, instead of throwing exception;

      • freezed package provide code generation of Generic type with union value. In stead of coding so many different types of failure message, and still require memorise your own definition of failures.
      • freezed generates mixin class naming like _$YourClassname<T>, so don't feel strange when you see class definition tailing with _$Blahblah, that means you are extending functions from freezed-genented code.
      • freezed generated code require part import into annotated class, see what is part import
    • using Monad to combine union type failure message at the left, and right is correction response.

      • dartz package provides Either class for this.
      • dartz functions like fold or getOrElse to check left or right value.
    • meta, foundation package

some concepts on the way

  • sealed class, in Kotlin if a class modifier with sealed that means in the definition file you have to define all possible subclasses of it. Once this is done, there will nowhere else can extend the sealed class.

    This means you can easily solid how many children class type a sealed class have.

  • mixin class, in Dart mixins are a way of reusing a class’s code in multiple class hierarchies. Because Dart is only one parent inheritance, you can't extend multiple classes, but using with keyword to reuse mixin classes functions.

The output of this lesson:

  • lib:

    • presentation
    • application/controller
    • domain
    • model

      • ValueObject extends AbstractValueObject, using validation in factory constructor.
    • common

      • AbstractValueObject, toString, hash, get methods, and dartz Either.
      • AbstractValueObjectValidation, wrap up Either object.
      • Failure @freezed, generate another part code for Validation to return Either union type.
    • infrastructure/repository