replacedFunction function

dynamic replacedFunction(
  1. StackFunction data
)

Implementation

replacedFunction(StackFunction data) {
  if (idStack.where((element) => element.id == data.id).isEmpty) {
    idStack.add(data);
  } else {
    idStack.where((element) => element.id == data.id).first.timer?.cancel();
    idStack.removeWhere((element) => element.id == data.id);
  }

  data.timer = Timer(const Duration(milliseconds: 500), () {
    idStack.removeWhere((element) => element.id == data.id);
    data.function();
  });
  idStack.add(data);
}