valueOrDefault method

dynamic valueOrDefault(
  1. Object? value
)

Returns value if non-null, otherwise returns the default value for this option.

For single-valued options, it will be defaultsTo if set or null otherwise. For multiple-valued options, it will be an empty list or a list containing defaultsTo if set.

Implementation

dynamic valueOrDefault(Object? value) {
  if (value != null) return value;
  if (isMultiple) return defaultsTo ?? <String>[];
  return defaultsTo;
}