optional<V> method
- @nonVirtual
Maps an optional named parameter of a constructor.
Parameter value
is the mapped value.
Parameter name
is the name of the named parameter.
Optional parameter kind
is the kind of the value. If omitted, the kind
is inferred from type parameter V
and value
using Kind.find.
Optional parameter defaultConstant
is the default value.
Optional parameter tags
is a list Trait instances such as
ProtobufFieldTag
.
The default implementation calls required.
Example
See ImmutableKind.
Implementation
@nonVirtual
V optional<V>(
V value,
String name, {
Kind<V>? kind,
Kind? superKind,
V? defaultConstant,
String? jsonName,
List<Trait> tags = const [],
}) {
if (kind != null && superKind != null) {
throw ArgumentError.value(
superKind,
'superKind',
'Must be null if kind is not null',
);
}
return handle<V>(
parameterType: ParameterType.optionalNamed,
value: value,
name: name,
kind: kind ?? superKind,
defaultConstant: defaultConstant,
jsonName: jsonName,
tags: tags,
);
}