'Is it possible to pass an instruction as a parameter in Dart?

I would like to know if there is a way to "pass an instruction as a parameter method", but i need that the instruction runs INTO the method but not in the parameter when I call that method.

Method:

_actionsCaller({dynamic arg1, dynamic arg2, dynamic arg3}) async {  
    _setDataState(Status.loading);    
    try {
      await arg1;
      await arg2;
      await arg3;    
     _setDataState(Status.completed);    
    } on CustomException catch (e) {
      _setFailure(e);
    }    
    notifyListeners();
  }

Passing the arguments:

 _actionsCaller(
      arg1: _dataRepository.deleteFirebaseApi(path: 'some path...'), // -> the instruction runs HERE, but not 'in' the _actionCaller method
      arg2: selectedClient.autos!.remove('some value...'), // -> the instruction runs HERE, but not 'in' the _actionCaller method
    );

Thanks for the answers ! =)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source