listFilesFromRoot method

Future<List<File>?> listFilesFromRoot(
  1. String folder
)

Implementation

Future<List<File>?> listFilesFromRoot(String folder) async{
  if(!await ready()) return null;
  try{
    var foldID = await getIDFromRoot(folder, mimeType: DriveQueryBuilder.folderMime);
    if(foldID == null) return null;
    return (await api!.files.list(
      spaces: (scope == DriveApi.driveAppdataScope) ? "appDataFolder" : "drive",
      q: "'$foldID' in parents"
    )).files;
  }catch(e, stack){
    if(e is PlatformException && e.code == "network_error"){
      return null;
    }
    if(kDebugMode){
      print("listFilesFromRoot:");
      print("${e.toString()}\n${stack.toString()}");
    }else if (onError != null){
      onError!(e, stack);
    }
    return null;
  }
}