import 'package:get/get.dart'; extension MapExtension on Map { T getWithSetCallback(K key, T Function() callback) { if (containsKey(key)) { return this[key]!; } else { var data = callback(); this[key] = data; return data; } } } extension RxMapExtension on RxMap { T getWithSetCallback(K key, T Function() callback) { if (containsKey(key)) { return this[key]!; } else { var data = callback(); this[key] = data; return data; } } }