flutter_onedrive 1.8.0 copy "flutter_onedrive: ^1.8.0" to clipboard
flutter_onedrive: ^1.8.0 copied to clipboard

Upload/download files to/from onedrive

Features #

  • Download files from onedrive
  • Upload files to onedrive
  • List files
  • Create directory
  • Delete files

References #

Read below documents before you start using this library:

Getting started #

flutter public add flutter_onedrive
import 'package:flutter_onedrive/flutter_onedrive.dart';

Usage #

final onedrive = OneDrive(redirectURL: "your redirect URL", clientID: "your client id");

return FutureBuilder(
  future: onedrive.isConnected(),
  builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
    if (!snapshot.hasData) {
      return const Center(child: CircularProgressIndicator());
    }
    if (snapshot.data ?? false) {
      // Has connected
      return const Text("Connected");
    } else {
      // Hasn't connected
      return MaterialButton(
        child: const Text("Connect"),
        onPressed: () async {
          final success = await onedrive.connect(context);
          if (success) {
            // Create directories
            OneDriveResponse response = await onedrive.createDirectory("/test");
            
            // Upload files
            const str = "Hello, World!";
            var data = Uint8List.fromList(utf8.encode(str));
            response = await onedrive.push(data, "/test/hello.txt");
            
            // Download files
            response = await onedrive.pull("/test/hello.txt");

            // List files
            final files = await onedrive.listFiles("/test/");

            // Delete files
            response = await onedrive.deleteFile("/test/hello.txt");

            // Delete directories
            response = await onedrive.deleteFile("/test");
          }
        },
      );
    }
  },
);
25
likes
130
points
219
downloads

Publisher

unverified uploader

Weekly Downloads

Upload/download files to/from onedrive

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_secure_storage, http, oauth_webauth, path, path_provider

More

Packages that depend on flutter_onedrive