FhirDecimal constructor
FhirDecimal(
- dynamic inValue
Implementation
factory FhirDecimal(dynamic inValue) {
if (inValue is FhirDecimal) {
return inValue;
} else if (inValue is FhirInteger) {
return FhirDecimal._(
inValue.toString(),
inValue.value?.toDouble(),
inValue.isValid,
inValue.isValid,
);
} else if (inValue is num) {
return FhirDecimal._(
inValue.toString(),
inValue.toDouble(),
true,
int.tryParse(inValue.toString()) != null,
);
} else if (inValue is String) {
final double? parsedDouble = double.tryParse(inValue);
if (parsedDouble != null) {
return FhirDecimal._(
inValue,
parsedDouble,
true,
int.tryParse(inValue) != null,
);
}
}
throw CannotBeConstructed<FhirDecimal>(
'Decimal cannot be constructed from $inValue ${inValue.runtimeType}');
}