Files
paperless-mobile/lib/extensions/dart_extensions.dart
Anton Stubenbord cb797df7d2 Initial commit
2022-10-30 14:15:37 +01:00

10 lines
227 B
Dart

extension NullableMapKey<K, V> on Map<K, V> {
V? tryPutIfAbsent(K key, V? Function() ifAbsent) {
final value = ifAbsent();
if (value == null) {
return null;
}
return putIfAbsent(key, () => value);
}
}