imsamgarg / firebase_cached_image

Cache Manager and Cached ImageProvider for Firebase Cloud Storage Objects.
MIT License
9 stars 16 forks source link

cache svg stored on firebase #21

Open prodigeomid opened 3 months ago

prodigeomid commented 3 months ago

Hello how i can cache svg using firebase ?

imsamgarg commented 3 months ago

This package supports caching any kind of file, But it can not render SVG because Flutter does not yet support SVG files. One workaround over this is to use FutureBuilder to get the cached file path and display the SVG image using the flutter_svg package.

Example

FutureBuilder<String>(
  future: FirebaseCacheManager()
        getSingleFile(FirebaseUrl("gs://bucket_f233/logo.svg")),
  builder: (context, snapshot) {
    if (snapshot.hasData) {
      final file = File(snapshot.data!);

      return SvgPicture.file(file);
    }

    // Handle error and loading states

    return const CircularProgressIndicator();
  },
);