Add Code
Map<String, BoraModel> _map;
_map = _map == null
? {updateKey: model}
: {..._notifications, updateKey: model};
Update Code
Map<String, BoraModel> _map;
_map.update(
updateKey,
(beforeVal) => model,
);
Delete Code
Map<String, BoraModel> _map;
_map.removeWhere((key, value) => key == updateKey);
πExample
model (VO)
class BoraModel {
final String x;
final String y;
BoraModel(
{this.x,
this.y});
}
enum Action {
Add,
Update,
Delete,
}
add, update, delete
Map<String, BoraModel> _map;
void _cudNotiMap(int actionIdx, String updateKey, BoraModel model) {
if (actionIdx == Action.Add.index) {
_map = _map == null
? {updateKey: model}
: {..._notifications, updateKey: model};
}
if (actionIdx == Action.Update.index) {
_map.update(
updateKey,
(beforeVal) => model,
);
}
if (actionIdx == Action.Delete.index) {
_map.removeWhere((key, value) => key == updateKey);
}
}