How to Integrate Google Drive APIs & Use Google Drive as Storage Bucket for flutter Application?

Integration of Google Drive APIs in flutter Application

In this article, we will figure out how to incorporate Google Drive APIs in the Flutter application. We will figure out how we can transfer, list, and download records to Google drive utilizing Flutter and use it as a storage alternative for an application. I have used Google login for validation and afterward got to Google drive. I have contemplated the Google Drive API however discovered this way is better and native toward the end. So how about we start our Google Drive execution in Flutter.

First of all, we have to set up the firebase project for our application to integrate the google login and google drive APIs. For setting up the project I suggest you go through this article of Vivek Yadav to integrate the firebase in a flutter.

After setting up the firebase then you have to turn on the google authentication from the firebase console.

Enable Google login in firebase Console

Now When you are done with the firebase integration than it's time to enable the Google Drive APIs from Google Developer Console go to the

Then follow the steps to enable Google Drive APIs

Step 1:

After Reaching the Google Developer Console then select your project as you see in the picture below the project name is just the same as you have recently created in firebase. In my case, It was Talaash (Just an example name).

Select the project from the google developer console

Step 2:

After selecting your project then click on the +Enable APIS and Services from the Google Developer Console dashboard

Enable APIS and Services

Step 3:

Then Search for Google Drive API you will see your desire API in the list

Step 4:

Now enable the API from here. In my case, it was already enabled.

Google Drive API

Now its Coding Time

The first and most basic step is to create a new application in Flutter.

Now, we will add the dependencies for implementing Google Drive Operations (Google API, Pick File to Upload & Download file in mobile storage). Please check the below dependencies.

 cupertino_icons: ^0.1.2  
firebase_auth: ^0.15.2
google_sign_in: ^4.1.0
flutter_secure_storage: ^3.3.1+1
googleapis: ^0.54.0
googleapis_auth: ^0.2.11
path_provider: ^1.5.1
file_picker: ^1.3.8

Add Permissions

For now, we are just using an android app for this example so we need to define permission for file reading and writing. For that define the following permissions in AndroidManifest File. (android/app/src/main/AndroidManifest.xml)

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />  
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>


Now, we will implement File Upload, Listing, and Download Login programmatically in main.dart file. Following is the class for mapping Google Auth Credential to GoogleHttpClient Credentials.

class GoogleHttpClient extends IOClient {  
Map<String, String> _headers;
GoogleHttpClient(this._headers) : super();
Future<http.StreamedResponse> send(http.BaseRequest request) =>
Future<http.Response> head(Object url, {Map<String, String> headers}) =>
super.head(url, headers: headers..addAll(_headers));

Following is the programming implementation of Google plus login, logout, file upload to Google drive, file download, and listing of uploaded files on Google drive.

Google Login:

Google Logout:

Upload File to Google Drive:

List Uploaded Files to Google Drive:

Download Google Drive File:

End Result

End result of Google Drive APIS integration in a flutter


We have learned how to integrate Google Drive in Flutter and perform the upload, download, and list operations.

Thank you for reading the article so far, and please let me your feedback. Tell me if you want another article with a more complex example. You can find the above app from my GitHub. If you liked my article, Please do clap and follow me on LinkedIn and Twitter. Thanks…

Source Code




Flutter developer, Mechatronics Engineer, Cats lover

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Adding Limited Ammo To Your Game

Mastering Android App Widgets

Generating android aab/apk from your react native app.

Setting up Android Development workbench using Flutter and Android Studio on Ubuntu 16.04 Desktop

Lightning Round: Android Gradient Floating Action Button

Working with Spreadsheets in Flutter: Part 1

Constraint Layout with Coordinatorlayout Layout & BottomAppBar

How To Validate Emails in Flutter

Inbox on phone

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
Arsalan umar

Arsalan umar

Flutter developer, Mechatronics Engineer, Cats lover

More from Medium

Let’s Dive Into Flutter…..

Today’s discovery: Using mockito with flutter.

Flutter101: [part-2] impatient guide Riverpod providers when to use what?

Android & iOS Previews for every Pull Request with Codemagic