← Back to list

How I Let Users Pick Files Directly from Google Drive in My Flutter App

When we building a Flutter app, file selection usually starts with the device itself. We use a file picker, open the device storage, and…

Ankit Mehra · 2026-08-26 07:56 · 150 claps · 5.8 min read
#flutter #android #ios #dart #google-drive-api
Open on Medium ↗
Wiki topics: RAG · RAG & Retrieval 📱 · Mobile Development 🏛️ · Politics

How I Let Users Pick Files Directly from Google Drive in My Flutter App

When we building a Flutter app, file selection usually starts with the device itself. We use a file picker, open the device storage, and let users select a document, image, video, or another file. But sometimes, the file our users want is not stored on their phone.

It is sitting in Google Drive.

I recently explored a package called **google_drive_file_picker** that makes it possible to browse and select files directly from Google Drive inside a Flutter application.

Instead of asking users to manually download a file from Google Drive and then select it again from their device, we can give them a more direct flow.

In this article, i will explain you that how i used it.

The problem i wanted to solve

Imagine we are building an application where users need to upload documents.

Normally, the flow might look something like this:

(i). Open the Google Drive app.

(ii). Find the required file.

(iii). Download it to the device.

(iv). Return to our application.

(v). Open the file picker.

(vi). Find the downloaded file.

(vii). Select and upload it.

That is a lot of unnecessary work.

A better experience would be:

Open Google Drive → Browse files → Select a file.

That is exactly the type of experience i wanted to create.

What is **google_drive_file_picker**?

**google_drive_file_picker** is a Flutter package that helps us interact with Google Drive for file selection.

The package provides functionality for:

(i). Google authentication

(ii). Browsing Google Drive files and folders

(iii). Searching and filtering files

(iv). Selecting a file

(v). Retrieving or downloading the selected file

This means we do not have to build the complete Google Drive browsing experience from scratch.

Adding the package

We have to add the **google_drive_file_picker package in our pubspec.yaml** file.

dependencies:
  google_drive_file_picker: ^0.0.2

Then we have to run this command in our terminal for install the package.

flutter pub get

After that, i imported the package where i wanted to use it.

import 'package:google_drive_file_picker/google_drive_file_picker.dart';

Creating the Google Drive Controller

The package provides a GoogleDriveController that handles the interaction with Google Drive.

I created an instance like this:

final GoogleDriveController controller = GoogleDriveController();

Before trying to access Google Drive, we need to configure our Google Cloud project correctly.

According to the package setup, we also provide the API key to the controller.

controller.setAPIKey(
  apiKey: 'our_api_key',
);

For a real application, i would avoid casually exposing sensitive configuration and make sure the Google Cloud setup follows Google’s security recommendations.

Setting Up Google Cloud

Before our Flutter application can interact with Google Drive, we need to configure Google Cloud.

The basic process is:

(1). Create a project in Google Cloud Console.

(2). Enable the Google Drive API.

(3). Configure authentication.

(4). Set up the OAuth consent screen.

(5). Add the required Google Drive permissions.

For reading files, the package documentation mentions the following scope:

https://www.googleapis.com/auth/drive.readonly

This permission allows our application to read files from the user’s Google Drive.

Authentication is an important part of this flow because an API key alone does not give an application permission to access a user’s private Google Drive files. Access to user data requires the appropriate OAuth authentication and scopes.

Connecting Google Sign-In

Since users need to access their own Google Drive files, we also need to handle Google authentication.

The package documentation points to the **google_sign_in **package for setting up Google Sign-In.

The general idea is simple:

User opens file picker
        ↓
User signs in with Google
        ↓
Required permissions are granted
        ↓
Google Drive becomes accessible
        ↓
User browses files
        ↓
User selects a file

Once authentication and permissions are configured correctly, we can move on to the actual file selection.

Opening the Google Drive File Picker

This was the part i found especially simple.

To open the picker i used:

final file = await controller.getFileFromGoogleDrive(
  context: context,
);

That is the main interaction.

The package handles the Google Drive browsing interface, allowing the user to navigate through available files and make a selection.

A simple example could look like this:

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

class GoogleDrivePickerPage extends StatefulWidget {
  const GoogleDrivePickerPage({super.key});

  @override
  State<GoogleDrivePickerPage> createState() => _GoogleDrivePickerPageState();
}

class _GoogleDrivePickerPageState extends State<GoogleDrivePickerPage> {
  final GoogleDriveController controller = GoogleDriveController();

  @override
  void initState() {
    super.initState();

    controller.setAPIKey(
      apiKey: 'your_api_key',
    );
  }

  Future<void> pickFile() async {
    final file = await controller.getFileFromGoogleDrive(
      context: context,
    );

    if (file != null) {
      debugPrint('File selected: $file');
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Google Drive File Picker'),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: pickFile,
          child: Text('Pick File from Google Drive'),
        ),
      ),
    );
  }
}

Now, whenever the user taps the button, the Google Drive file selection flow can begin.

Handling the Selected File

Once a user selects a file, we can check whether a file was returned.

The basic idea is:

final file = await controller.getFileFromGoogleDrive(
  context: context,
);

if (file != null) {
  // Use the selected file
}

What we do next depends on our application.

For example, we might want to:

(i). Upload the file to our backend

(ii). Display the file name

(iii). Download the file locally

(iv). Attach it to a support request

(v). Use it as a document upload

(vi). Preview the selected file

For example:

Future<void> pickFile() async {
  final file = await controller.getFileFromGoogleDrive(
    context: context,
  );

  if (file == null) {
    debugPrint('No file selected');
    return;
  }

  debugPrint('Selected file: $file');

  // Continue with our upload or processing logic
}

I also prefer handling the null case properly because users can always close or cancel the picker without selecting anything.

Why this can improve the User Experience

What I like about this approach is that it removes an unnecessary step.

Without direct Google Drive selection:

Google Drive
     ↓
Download file
     ↓
Open our app
     ↓
Open device file picker
     ↓
Find downloaded file
     ↓
Select file

With Google Drive file selection:

Our Flutter App
      ↓
Open Google Drive
      ↓
Browse files
      ↓
Select file

The second flow feels much more direct.

For users who keep most of their documents in Google Drive, this can make a noticeable difference.

Where we can use this

I can see this being useful in many types of Flutter applications.

(i). Document Upload Apps

Users can select:

  • PDFs
  • Resumes
  • Certificates
  • Identity documents
  • Reports

directly from Google Drive.

(ii). Job Applications

Instead of requiring users to keep a copy of their resume on their device, we can allow them to select it directly from Google Drive.

(iii). Education Apps

Students often store assignments, notes, and documents in cloud storage.

A direct file picker could make submitting assignments much easier.

(iv). Business Applications

Employees frequently keep presentations, spreadsheets, and reports in Google Drive.

Allowing direct selection can reduce friction when uploading files.

(v). Support or Ticketing Systems

Users can attach screenshots, logs, documents, or other files directly from their Drive.

A few things to keep in mind

Even though the package simplifies the file picking experience, the Google configuration still matters.

Before integrating this into a production application, I would make sure to test:

(i). Google Sign-In

(ii). OAuth configuration

(iii). Required scopes

(iv). Android configuration

(v). iOS configuration

(vi). Permission handling

(vii). User cancellation

(viii). Different file types

(ix). Large files

(x). Network failures

Google authentication can sometimes be the part that requires the most configuration, so it is worth testing the complete flow on a real device.

I would also make sure that the application requests only the permissions it actually needs.

My experience with it

What i liked most about **google_drive_file_picker **was the idea behind the package.

Building a complete Google Drive integration manually can involve authentication, API requests, file listing, folder navigation, search, selection, and downloading.

For an application that simply needs a Google Drive file selection experience, having a package that brings these pieces together can save a significant amount of development time.

The actual file-picking call is straightforward:

final file = await controller.getFileFromGoogleDrive(
  context: context,
);

Of course, the surrounding Google authentication and Cloud configuration still need to be set up correctly, but once that foundation is ready, the integration becomes much easier to work with.

Final Thoughts

Sometimes improving an application’s user experience is not about building a complicated new feature.

It can be as simple as removing a few unnecessary steps.

If our users already store their documents in Google Drive, asking them to manually download those files before selecting them in our application can feel inconvenient.

By allowing users to browse and pick files directly from Google Drive, we can make the process much smoother.

For my Flutter project, this approach gave me a simple starting point for integrating Google Drive file selection without building the entire browsing experience from scratch.

If our application involves document uploads, resumes, assignments, reports, or cloud-stored files, this is definitely an approach worth exploring.


메타데이터
post_id
2b87c5fc72ee
slug
how-i-let-users-pick-files-directly-from-google-drive-in-my-flutter-app-2b87c5fc72ee
url
https://medium.com/@ankii8946/how-i-let-users-pick-files-directly-from-google-drive-in-my-flutter-app-2b87c5fc72ee
canonical_url
https://medium.com/@ankii8946/how-i-let-users-pick-files-directly-from-google-drive-in-my-flutter-app-2b87c5fc72ee
author_url
https://medium.com/@ankii8946
status
ok
fetched_at
2026-08-30 23:39:38