A cached Flutter ImageProvider for Firebase Cloud Storage image objects

Overview

🔥 Firebase Image Provider

pub package

A cached Flutter ImageProvider for Firebase Cloud Storage image objects.

How to use

Make sure you already have Firebase set up on all platforms you want to use this on.

Supply the FirebaseImage widget with the image's URI (e.g. gs://bucket123/userIcon123.jpg) and then put that in any widget that accepts an ImageProvider (most image related widgets will (e.g. Image, ImageIcon, etc.)). Please note that you do need the gs:// prefix currently.

See the below for example code.

How does it work?

The code downloads the image (object) into memory as a byte array.

Unless disabled using the cacheRefreshStrategy: CacheRefreshStrategy.NEVER option, it gets the object's last update time from metadata (a millisecond precision integer timstamp) and uses that as a defacto version number. Therefore, any update to that remote object will result in the new version being downloaded.

The image byte array in memory then gets saved to a file in the temporary directory of the app and that location is saved in a persistant database. The OS can clean up this directory at any time however.

Metadata retrival is a 'Class B Operation' and has 50,000 free operations per month. After that, it is billed at $0.04 / 100,000 operations and so the default behaviour of cacheRefreshStrategy: CacheRefreshStrategy.BY_METADATA_DATE may incur extra cost if the object never changes. This makes this implementation a cost effective stratergy for caching as the entire object doesn't have to be transfered just to check if there have been any updates. Essentailly, any images will only need to be downloaded once per device.

Example

import 'package:flutter/material.dart';
import 'package:firebase_image/firebase_image.dart';

class IconImage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Firebase Image Provider example'),
      ),
      body: Image(
        image: FirebaseImage('gs://bucket123/userIcon123.jpg'),
        // Works with standard parameters, e.g.
        fit: BoxFit.fitWidth,
        width: 100,
        // ... etc.
      ),
    );
  }
}

To Do

  • Add examples to pub.dev
  • Clear items from cache if they haven't been accessed after a certain amount of time (2 weeks?)
  • Add more documentation/comments
  • Create unit tests

Contributing

If you want to contribute, please fork the project and play around there!

If you're stuck for ideas, check Issues or the above To Do list for inspiration.

Please check PRs and other peoples forks to see if anyone is working on something similiar to what you want to do.

Once you're ready, please submit a pull request.

You might also like...

Dota 2 App using Firebase and Google Cloud

Dota 2 App using Firebase and Google Cloud

Dota 2 App using Firebase and Google Cloud This is a pet project that born with the idea of having a nice subject to go through some Live Coding sessi

Dec 15, 2022

Aprendendo a usar notificações Push com o Firebase Cloud Messaging

Notificações Push com Firebase Esse projeto foi desenvolvido com base no curso "Flutter: Push notifications com Firebase Cloud Messaging", da Alura. P

Dec 28, 2021

Build an example app for receiving notification from Firebase Cloud Messaging (FCM)

notify Build an app demo for receiving notifications from Firebase Cloud Messaging. Check more information: https://firebase.google.com/docs/cloud-mes

Dec 9, 2022

Awesome Notifications add-on plugin to enable push notifications through Firebase Cloud Messaging with all awesome notifications features.

Awesome Notifications add-on plugin to enable push notifications through Firebase Cloud Messaging with all awesome notifications features.

Awesome Notifications FCM Awesome Notifications add-on to send push notifications using FCM (Firebase Cloud Messaging), with all awesome notifications

Jan 4, 2023

Flutter package to create list of radio button, by providing a list of objects it can be a String list or list of Map.

Flutter package to create list of radio button, by providing a list of objects it can be a String list or list of Map.

Custom Radio Group List Flutter package to create list of radio button, by providing a list of objects it can be a String list or list of Map. Feature

Nov 30, 2021

FIDL(Flutter Interface Definition Language) is a language for transfer objects cross platforms.

FIDL(Flutter Interface Definition Language) is a language for transfer objects cross platforms.

Flutter Interface Definition Language (FIDL) README in English(TODO) FIDL 即 Flutter 接口定义语言,类似于AIDL(Android Interface Definition Language)。您可以利用它定义不同平台

Dec 7, 2022

A highly customizable Flutter widget to render and interact with JSON objects.

A highly customizable Flutter widget to render and interact with JSON objects.

The spreadsheet with superpowers ✨ ! JSON Data Explorer A highly customizable widget to render and interact with JSON objects. Features Expand and col

Dec 21, 2022

Picture upload widget for Flutter which helps selecting and uploading one or multiple images to firebase storage.

Picture upload widget for Flutter which helps selecting and uploading one or multiple images to firebase storage.

Flutter Firebase Picture Uploader This library offers a Picture Upload widget which can be used to upload one or multiple images to your Firebase Stor

Oct 21, 2022

A working Twitter clone written in Flutter using Firebase auth,realtime,firestore database and storage

A working Twitter clone written in Flutter using Firebase auth,realtime,firestore database and storage

A working Twitter clone written in Flutter using Firebase auth,realtime,firestore database and storage

Dec 24, 2022
Owner
KaHero
KaHero
A font loader to download, cache and load web fonts in flutter with support for Firebase Cloud Storage.

Dynamic Cached Fonts A simple, easy to use yet customizable font loader to use web fonts. Demo: https://sidrao2006.github.io/dynamic_cached_fonts ?? I

Aneesh Rao 18 Dec 21, 2022
Cloud storage status

cloud_storage_status Get me a coffee: Bitcoin Address: 1DiFn7B9APaQJKfYAKqesnGM2eVM1MW6U Ethereum Address: 0xAdc43dadbE2b64DC9ba1c8766764F7cD4a2Fa915

Cybdom 38 Jul 23, 2021
Download files from Firebase Storage with Flutter. List all images, videos, or other files from Firebase and download them.

Flutter Tutorial - Download Files From Firebase Storage Download files from Firebase Storage with Flutter. List all images, videos, or other files fro

Johannes Milke 28 Dec 4, 2022
Upload Files To Firebase Storage with Flutter. Pick images, videos, or other files from your device and upload them to Firebase.

Flutter Tutorial - Upload Files To Firebase Storage Upload Files To Firebase Storage with Flutter. Pick images, videos, or other files from your devic

Johannes Milke 30 Dec 28, 2022
Project demonstrates building a simple chat application using Flutter framework and Firebase cloud

Flutter Chat on Firebase Project demonstrates building a simple chat application using Flutter framework and Firebase cloud. App does not poll for new

Sukitha Udugamasooriya 8 Feb 2, 2022
A Flutter application that demonstrate simple CRUD operations with Firebase cloud database.

Cricket Team A Flutter application that demonstrate simple CRUD operations with Firebase cloud database. Preview Home Empty Swipe Add Player Update Pl

Bhavik Makwana 45 Jun 19, 2021
Flutter push notifications with Firebase Cloud Messaging.

Notify A Flutter sample app demonstrating how to send push notifications using Firebase Cloud Messaging (FCM). Screenshots Notification while the app

hebaabdelwhab 0 Dec 24, 2021
Gcloud-flutter-dota-app - Dota 2 App using Firebase and Google Cloud

Dota 2 App using Firebase and Google Cloud This is a pet project that born with the idea of having a nice subject to go through some Live Coding sessi

Alvaro Viebrantz 39 Dec 15, 2022
Notey - A noteApp build using flutter with firebase cloud firestore

notey A project to create and store notes for later purposes. Notey is built usi

Al-amin O. 1 Aug 14, 2022
The prime objective of this app is to store the real time information of the user using firebase cloud firestore and also can delete, remove and update the customer information

crud_firestore A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started i

Muhammad Zakariya 0 Mar 15, 2022