from<K, V> static method
FutureOr<SharedMap<K, V> >
from<K, V>({
- SharedMapReference? reference,
- String? id,
- SharedMapEventCallback? onInitialize,
- SharedMapKeyCallback<
K, V> ? onAbsent, - SharedMapEntryCallback<
K, V> ? onPut, - SharedMapEntryCallback<
K, V> ? onRemove,
Creates a SharedMap from reference
or id
.
Implementation
static FutureOr<SharedMap<K, V>> from<K, V>(
{SharedMapReference? reference,
String? id,
SharedStoreReference? sharedStoreReference,
SharedStore? sharedStore,
String? sharedStoreID,
SharedMapEventCallback? onInitialize,
SharedMapKeyCallback<K, V>? onAbsent,
SharedMapEntryCallback<K, V>? onPut,
SharedMapEntryCallback<K, V>? onRemove}) {
if (reference != null) {
return SharedMap.fromSharedReference(reference)
..setCallbacks(
onInitialize: onInitialize,
onAbsent: onAbsent,
onPut: onPut,
onRemove: onRemove);
}
if (id != null) {
sharedStore ??=
SharedStore.from(reference: sharedStoreReference, id: sharedStoreID);
return SharedMap.fromID(sharedStore, id,
onInitialize: onInitialize,
onAbsent: onAbsent,
onPut: onPut,
onRemove: onRemove);
}
throw MultiNullArguments(['reference', 'id']);
}