orNull<T> static method
If Iterable is null
, return null
.
Otherwise, create an ISet from the Iterable. Fast, if the Iterable is another ISet.
This static factory is useful for implementing a copyWith
method
that accept an Iterable. For example:
ISet<String> names;
Students copyWith({Iterable<String>? names}) =>
Students(names: ISet.orNull(names) ?? this.names);
Of course, if your copyWith
accepts an ISet, this is not necessary:
ISet<String> names;
Students copyWith({ISet<String>? names}) =>
Students(names: names ?? this.names);
Implementation
static ISet<T>? orNull<T>(
Iterable<T>? iterable, [
ConfigSet? config,
]) =>
(iterable == null) ? null : ISet.withConfig(iterable, config ?? defaultConfig);