Firebase Storage — Flutter 💙💛

Storing images and files to your server is a hectic task. But Firebase Storage has solved this problem to a great extent! Let’s see how we can use it!

Firebase is one of the services that provide many functionalities that you can use in your web and mobile applications! Initially, when we wanted to store images and files in our database, it was a hectic task! Firebase Storage is a service that allows you to store files and images into cloud storage with ease and significantly less amount of code!

To start with Firebase Storage, there are the following steps involved:

  • Enable storage from the console.
  • Create code for different operations of storage.

Step 1: Enable Storage from the Console

Go to the Firebase Console and open your project. On the right panel, click on the Storage option, and it will bring you to a welcome/introduction page where you can click on Get Started button! Follow the next steps and enable the Firebase Storage.

Step 2: Upload Files to Storage

Firebase Storage code is really short and easy to do. Let’s see how you can add an upload operation for Firebase Storage!

You can upload a file in either way:

  • Uint8List
  • From a path
  • From a local file

Here, we have uploaded the image in form of Uint8List! You can see the code is just 1 line and this will upload the file with the provided file name to your storage bucket!

Step 3: Get the Download URL

Once the image is uploaded, you can get the download URL of that image so that you can use NetworkImage to show the particular image.

Step 4: Delete the file

Well, keeping unwanted files in storage would be useless. It’s always a good practice to delete the file when the user is deleted.

So, your entire service file would look like the following:

And that’s it!!!

Hope you enjoyed this article!

Feel free to try it yourself by cloning the GitHub Repository!

Doubts? Feel free to drop a message @AbhishekDoshi26

Don’t stop, until you are breathing!💙
- Abhishek Doshi

--

--

--

Experts on various Google products talking tech.

Recommended from Medium

State of the EV: An Early Case Study

OAuth, wherefore art thou?

I have one month to make an MMO: Day 12

How to Hack C++ Code

Using reflection in Golang

Introduction to Processor Level Error Handling in Anypoint Platform(Mule 4) Part-3

This week in #Scala (Jun 20, 2022)

BASIC DATA TYPES IN PYTHON

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhishek Doshi

Abhishek Doshi

Google Developer Expert — Dart, Flutter & Firebase 💙💛

More from Medium

Firestore Database — Flutter💙💛

Mastering AWS Amplify’s SMS Flows in Flutter — Part 4: Sign In Flow

Add Firebase to Flutter on Windows

How to Integrate Ortho in Your Flutter App