DioImageProvider constructor

DioImageProvider({
  1. required Uri imageUrl,
  2. required String fallbackAssetPath,
})

Creates a new DioImageProvider instance.

The provider will attempt to load the image from imageUrl first. If that fails for any reason (network error, invalid response, etc.), it will automatically fall back to loading the image from fallbackAssetPath.

The internal Dio instance is automatically configured with the following interceptors:

Parameters:

  • imageUrl: The network URL of the image to load
  • fallbackAssetPath: The asset path to use if the network image fails to load

Implementation

DioImageProvider({
  required this.imageUrl,
  required this.fallbackAssetPath,
}) : dio = Dio() {
  if (!kIsWeb) {
    dio.interceptors.add(
      SupaArchitecturePlatform.instance.cookieStorage.interceptor,
    );
  }
  dio.interceptors.add(DeviceInfoInterceptor());
  dio.interceptors.add(TimezoneInterceptor());
  dio.interceptors.add(RefreshInterceptor());
}