flutter_onedrive 1.0.1
flutter_onedrive: ^1.0.1 copied to clipboard
Upload/download files to/from onedrive
Features #
- Download files from onedrive
- Upload files to onedrive
References #
Read below documents before you start using this library:
- https://docs.microsoft.com/en-us/onedrive/developer/rest-api/getting-started/msa-oauth?view=odsp-graph-online
- https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher
Getting started #
flutter public add flutter_onedrive
import 'package:flutter_onedrive/flutter_onedrive.dart';
Usage #
final onedrive = OneDrive(callbackSchema: "your callback schema", clientID: "your client id");
return FutureBuilder(
future: onedrive.isConnected(),
builder: (context, AsyncSnapshot<bool> snapshot) {
if (!snapshot.hasData) {
return const Center(child: CircularProgressIndicator());
}
if (snapshot.data ?? false) {
// Has connected
// return Some Widgets...
} else {
// Hasn't connected
final success = await onedrive.connect();
if (success) {
// Download files
final txtBytes = await onedrive.pull("/xxx/xxx.txt");
// Upload files
await onedrive.push(txtBytes!, "/xxx/xxx.txt");
}
// return Some Widgets...
}
}
)