fromValue4<T0, T1, T2, T3> static method
OneOf4<T0, T1, T2, T3>
fromValue4<
T0, T1, T2, T3>({ - required Object? value,
- int? typeIndex,
- Type? type,
})
Implementation
static OneOf4<T0, T1, T2, T3> fromValue4<T0, T1, T2, T3>({
required Object? value,
int? typeIndex,
Type? type,
}) {
typeIndex = _guessTypeIndex(
types: [T0, T1, T2, T3],
type: type,
typeIndex: typeIndex,
value: value,
);
if (typeIndex == null) {
//try to determine typeIndex by checking value type
if (value is T0) {
typeIndex = 0;
} else if (value is T1) {
typeIndex = 1;
} else if (value is T2) {
typeIndex = 2;
} else if (value is T3) {
typeIndex = 3;
}
}
_throwIfFailedAttempt(typeIndex);
return OneOf4(value: value, typeIndex: typeIndex!);
}