valueOrDefault method

dynamic valueOrDefault(
  1. dynamic 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(value) {
  if (value != null) return value;
  if (isMultiple) return defaultsTo ?? <String>[];
  return defaultsTo;
}