setValueOrDisplayError method

void setValueOrDisplayError(
  1. Future<ServiceResult> futureServiceResult,
  2. Function setter,
  3. Function errorHandler, {
  4. dynamic additionalParam,
})

Main method to call for instance when a button is clicked. example: setValueOrDisplayError(restSimplified.get

Implementation

void setValueOrDisplayError(Future<ServiceResult> futureServiceResult,
    Function setter, Function errorHandler,
    {var additionalParam}) {
  futureServiceResult.then((value) => {
        _callBackSet(setter, errorHandler, value,
            additionalParam: additionalParam)
      });
  futureServiceResult.catchError((error) {
    return ServiceResult.onInternalError(error.toString());
  });
}