Skip to content

Latest commit

 

History

History
57 lines (47 loc) · 2.34 KB

README.md

File metadata and controls

57 lines (47 loc) · 2.34 KB

Drive Helper

Drive Helper is an easy to use library for interfacing with Google Drive and Google sign in.
It is a thin wrapper around google_sign_in and googleapis, making it much more intuitive for developers to use and integrate Google Drive into a project. If you already use the Drive API, then you probably have a wrapper class for initialisation and read/write, you can likely easily replace it with Drive Helper.

Get started

Follow the instruction in the tutorial to start using Drive Helper in your Flutter project, or migrate to it for an existing app.

Features

  • Signs in to Google and maintains the account for you
  • Exposed DriveAPI, GoogleSignIn, and GoogleSignInAccount to help with possibly missing functionality
  • Provides methods for
    • Signing in to and signing out or disconnecting from Google accounts
    • Searching, creating, reading, overwriting, appending, and deleting files
    • Getting the account's name, email address, or avatar
  • Predefined MIME types for use in creating and exporting files
  • Predefined permission scopes for easily picking a suitable permission level apt for your purposes

Example

To have a look at an app that uses this library, see the app that inspired Drive Helper, BP Logger.

The code below shows how to initialise the library:

class MyApp extends StatelessWidget {
  late DriveHelper driveHelper;

  Widget build() {
    return MaterialApp(
      // Theming and other setting
      body: FutureBuilder(
        future: () async => await driveHelper = DriveHelper.initialise([
            // Choose your scopes
        ]),
        builder: (snapshot, context) {
          if (snapshot.connectionState == ConnectionState.done &&
            !snapshot.hasError) {
            return HomePage(driveHelper: driveHelper);
          } else if (snapshot.connectionState == ConnectionState.done &&
            snapshot.hasError) {
            return ErrorPage(error: snapshot.error);
          } else {
            return Container(
              width: MediaQuery.of(context).size.width / 1.5,
              height: MediaQuery.of(context).size.width / 1.5,
              child: CircularProgrssIndicator(strokeWidth: 10),
            );
          }
        }
      ),
    );
  }
}