I want to upload multiple image to the google drive. I am using flutter null safety version and using one example https://www.c-sharpcorner.com/article/google-drive-integration-in-flutter-upload-download-list-files/ . In above example the writer is using old version of flutter .
I am using file_picker: ^4.2.1 and the code which is throwing error:
var client = GoogleHttpClient(await googleSignInAccount!.authHeaders);
var drive = ga.DriveApi(client);
ga.File fileToUpload = ga.File();
var file = await FilePicker.platform.pickFiles(
type: _pickingType,
allowMultiple: _multiPick,
onFileLoading: (FilePickerStatus status) => print(status),
allowedExtensions: (_extension?.isNotEmpty ?? false)
? _extension?.replaceAll(' ', '').split(',')
: null,
);
fileToUpload.parents = ["appDataFolder"];
fileToUpload.name = path.basename(file!.paths);
var response = await drive.files.create(
fileToUpload,
uploadMedia: ga.Media(file.openRead(), file.lengthSync()),
);
print(response);
_listGoogleDriveFiles();
}```
and errors are:
1. The argument type 'List<String?>' can't be assigned to the parameter type 'String'.
2. The method 'openRead' isn't defined for the type 'FilePickerResult'.
3. The method 'lengthSync' isn't defined for the type 'FilePickerResult'.
Error is mainly because of the different version of file_picker package . Can you please suggest me other package or the change that could done in the code.