orNull<K, V> static method
If mapOfSets
is null
, return null
.
Otherwise, create an IMapOfSets from the mapOfSets
.
This static factory is useful for implementing a copyWith
method
that accept regular map of sets. For example:
IMapOfSets<Course, String> studentsPerCourse;
Students copyWith({ Map<Id, Iterable<String>>? studentsPerCourse }) =>
Students(studentsPerCourse: IMapOfSets.orNull(studentsPerCourse) ?? this.studentsPerCourse);
Of course, if your copyWith
accepts an IMapOfSets, this is not necessary:
IMapOfSets<Id, String> studentsPerCourse;
Students copyWith({ IMapOfSets<Id, String>? studentsPerCourse }) =>
Students(studentsPerCourse: studentsPerCourse ?? this.studentsPerCourse);
Implementation
static IMapOfSets<K, V>? orNull<K, V>(
Map<K, Iterable<V>>? map, [
ConfigMapOfSets? config,
]) =>
(map == null) ? null : IMapOfSets.withConfig(map, config ?? defaultConfig);