fromValue3<T0, T1, T2> static method
OneOf3<T0, T1, T2>
fromValue3<
T0, T1, T2>({ - required Object? value,
- int? typeIndex,
- Type? type,
})
Implementation
static OneOf3<T0, T1, T2> fromValue3<T0, T1, T2>({
required Object? value,
int? typeIndex,
Type? type,
}) {
typeIndex = _guessTypeIndex(
types: [T0, T1, T2],
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;
}
}
_throwIfFailedAttempt(typeIndex);
return OneOf3(value: value, typeIndex: typeIndex!);
}