modddels icon indicating copy to clipboard operation
modddels copied to clipboard

Support Dart 3.0 Record Type

Open CodingSoot opened this issue 2 years ago • 2 comments

CodingSoot avatar May 14 '23 10:05 CodingSoot

Hi,

I got an actual use-case for this: a Duration value-object of the form ({double max, double? min}) to be used to control a UI notification’s duration (min = 0.0 by default).

chikamichi avatar Jun 07 '23 22:06 chikamichi

Hi @chikamichi ,

Wouldn't a MultiValueObject be fine ?

// @Modddel( ...
class Duration extends MultiValueObject<InvalidDuration, ValidDuration>
    with _$Duration {
  Duration._();

  factory Duration({
    required double max,
    double min = 0.0,
  }) {
    return _$Duration._create(
      max: max,
      min: min,
    );
  }

  //..
}

Or do you specifically like the Record syntax ?

CodingSoot avatar Jun 07 '23 22:06 CodingSoot