How to get folder list from google drive?

1,059

You can get the Folder List using Query Parameters in List() method.

Code:

var f = await drive.files
        .list(q: "mimeType = 'application/vnd.google-apps.folder'");
    f.files.forEach((f) {
      print(f.size);
    });
    print("Result ${f.toJson()}");
Share:
1,059
Hiren H. Patel
Author by

Hiren H. Patel

Updated on December 13, 2022

Comments

  • Hiren H. Patel
    Hiren H. Patel over 1 year

    I am trying to get the list of folders and files available in google drive. But I am stuck to get folder name and it's detailed using dart and flutter.

    I am able to get the file list but unable to get folder list.

        var drive = ga.DriveApi(client);
        var f = await drive.files.list();
        for (var item in f.files) {
          print(item.name);
        }
    

    I have just gone through this video(https://www.youtube.com/watch?v=9kXov_Ly9BI) and created an application. In that video, it shows me how to upload the files to google drive and I want to get the list of files/folder from google drive. I am able to get file name but unable to get folder details.