getOptionValues method

  1. @override
List<String>? getOptionValues(
  1. String name
)
override

Returns a list of values associated with a given option name.

Behavior:

  • If the option is present without a value (--flag), returns an empty list [].
  • If the option has one value (--name=John), returns ['John'].
  • If the option has multiple values (--name=John --name=Doe), returns ['John', 'Doe'].
  • If the option is not present, returns null.

Example:

final names = args.getOptionValues('name');
if (names != null) {
  print(names); // might print: ['Alice', 'Bob']
}

@param name the name of the option. @return list of values or null if the option is not present.

Implementation

@override
List<String>? getOptionValues(String name) {
  List<String>? values = source.getOptionValues(name);
  return (values != null) ? List.unmodifiable(values) : null;
}