Firebase Storage — Flutter

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

Firebase Storage — Flutter 💙💛 was originally published in Google Developers Experts on Medium, where people are continuing the conversation by highlighting and responding to this story.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

What’s the Shape Up Methodology and How to Use it To Build Meaningful Products

Next Post

Google Workplace GDE Alice Keeler on balancing responsibilities and using coding as self-care

Related Posts