Option<T extends CandidType?> constructor

Option<T extends CandidType?>({
  1. T? value,
  2. T? value_type,
  3. bool type_mode = false,
})

Implementation

Option({this.value, this.value_type, this.type_mode=false}) {
    if (type_mode==true) {
        if (value_type==null) {
            throw Exception('for an Option as a type-stance is with the value_type-parameter-quirement by the class-rules.');
        }
        if (value!=null) {
            throw Exception('for an Option as a type-stance is with the value-parameter-null-quirement by the class-rules.');
        }
    } else {
        if (value==null && value_type==null) {
            throw Exception('an Option needs either a CandidType value, or if the value is null: an Option needs the value_type-parameter set to a CandidType-[in]stance with the type_mode=true');
        }
    }
    if (value_type!=null) {
        if (value_type!.type_mode==false) {
            throw Exception('The value_type CandidType must have .type_mode == true');
        }
    }
}