optionalPositional<V> method

  1. @nonVirtual
V optionalPositional<V>(
  1. V value,
  2. String name, {
  3. Kind<V>? kind,
  4. Kind? superKind,
  5. V? defaultConstant,
  6. String? jsonName,
  7. List<Trait> tags = const [],
})

Maps an optional positional parameter of a constructor.

Parameter value is the mapped value.

Parameter name is the name of the positional 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 positional.

Example

See ImmutableKind.

Implementation

@nonVirtual
V optionalPositional<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.optionalPositional,
    value: value,
    name: name,
    kind: kind ?? superKind,
    defaultConstant: defaultConstant,
    jsonName: jsonName,
    tags: tags,
  );
}