You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
535 B
Dart
26 lines
535 B
Dart
import 'package:get/get.dart';
|
|
|
|
extension MapExtension<K, T> on Map<K, T> {
|
|
T getWithSetCallback(K key, T Function() callback) {
|
|
if (containsKey(key)) {
|
|
return this[key]!;
|
|
} else {
|
|
var data = callback();
|
|
this[key] = data;
|
|
return data;
|
|
}
|
|
}
|
|
}
|
|
|
|
extension RxMapExtension<K, T> on RxMap<K, T> {
|
|
T getWithSetCallback(K key, T Function() callback) {
|
|
if (containsKey(key)) {
|
|
return this[key]!;
|
|
} else {
|
|
var data = callback();
|
|
this[key] = data;
|
|
return data;
|
|
}
|
|
}
|
|
}
|