fetchData<T> abstract method

Future<NimphelosModel<T, dynamic>> fetchData<T>({
  1. required Future<T> response(),
  2. BuildContext? context,
  3. bool activeAlert = true,
  4. bool activeWillAlwaysWork = true,
  5. bool generalFunction<E>(
    1. E? exception
    )?,
  6. dynamic willAlwaysWork<E>(
    1. E exception
    )?,
  7. DioExceptionHandlerModel? exceptionDioHandlers,
  8. JsonExceptionHandlerModel? exceptionJsonHandlers,
  9. FormatExceptionHandlerModel? exceptionFormatHandlers,
  10. ExceptionHandlerModel? exceptionHandlers,
})

Fetches data from a service and returns a NimphelosModel containing the result.

  • response is a required function that returns a Future containing the response data.
  • context is an optional parameter representing the current build context.
  • activeAlert determines if an alert should be shown in case of an error (default is true).
  • activeWillAlwaysWork determines if the exception handler should be activated (default is true).
  • generalFunction is a function to handle exceptions of type E, when a specific function is not provided, and context is null. It is only invoked in this case.
  • willAlwaysWork is a function to handle specific exceptions and will always be invoked.
  • exceptionDioHandlers contains a set of custom Dio exception handling functions.
  • exceptionJsonHandlers contains a set of custom JSON exception handling functions.
  • exceptionFormatHandlers contains a set of custom JSON format exception handling functions.
  • exceptionHandlers contains a set of custom exception handling functions.

Returns a NimphelosModel with the result of the service call.

Implementation

Future<NimphelosModel<T, dynamic>> fetchData<T>({
  required Future<T> Function() response,
  BuildContext? context,
  bool activeAlert = true,
  bool activeWillAlwaysWork = true,
  bool Function<E>(E? exception)? generalFunction,
  Function<E>(E exception)? willAlwaysWork,
  DioExceptionHandlerModel? exceptionDioHandlers,
  JsonExceptionHandlerModel? exceptionJsonHandlers,
  FormatExceptionHandlerModel? exceptionFormatHandlers,
  ExceptionHandlerModel? exceptionHandlers,
});