wrapPrimitive method
Attempt to wrap a Dart primitive value into a $Value. This is needed because Dart primitives cannot be implemented or extended, so creating a bimodal wrapper is impossible.
Implementation
$Value? wrapPrimitive(dynamic value) {
if (value is int) {
return $int(value);
} else if (value is double) {
return $double(value);
} else if (value is String) {
return $String(value);
} else if (value is bool) {
return $bool(value);
} else if (value == null) {
return $null();
}
return null;
}