Assert constructor

const Assert(
  1. String eval, [
  2. String? message
])

A decorator that allows adding assert(...) on the generated classes.

Usage example:

abstract class Person with _$Person {
  @Assert('name.trim().isNotEmpty', 'name cannot be empty')
  @Assert('age >= 0')
  factory Person({
    String name,
    int age,
  }) = _Person;
}

Implementation

const Assert(this.eval, [this.message]);