Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Sheets API v4 for Flutter/Dart

Will there be Google Sheets API v4 support for Dart/Flutter, if yes when is it coming? It already has support for many languages but Dart/Flutter is not listed in their guides.

like image 974
Din Avatar asked Sep 28 '17 10:09

Din


People also ask

How do I get data from Google sheets to flutter?

In the Flutter Calendar, get the data from the Google sheet using the Google AppScript, and load that data to the Flutter Calendar Events. STEP 2: Then, add the required data in the Google spreadsheet. STEP 3: Now, open the Google AppScript for corresponding spreadsheet data, and add the doGet() method.

Can Google sheets send Webhooks?

Zapier lets you send info between Google Sheets and Webhooks by Zapier automatically—no code required. Triggered when you create a new spreadsheet. automatically do this! Fire off a custom request by providing raw details.


3 Answers

googleapis package can be used in Flutter and supports Sheets v4

See also this similar Stack Overflow question

like image 150
Günter Zöchbauer Avatar answered Oct 03 '22 00:10

Günter Zöchbauer


I created a project, enabled the sheets API for it, then created a 'robot-style' service account, and download the key as JSON. I then created a Google Sheet, and made it publicly accessible, noting its key.

This code connects, and updates an existing sheet by appending a new line of data. No error handling, but some print() statements to help visualise the flow.

// Key for service account copied from downloaded file for demo purposes ;-)
final _key = {
  "type": "service_account",
  "project_id": //etc
  // ...
  // ...
};

print('getting oauth');
auth
    .obtainAccessCredentialsViaServiceAccount(
        auth.ServiceAccountCredentials.fromJson(_key),
        scopes,
        http.Client())
    .then((auth.AccessCredentials cred) {
  print('got oauth');

  auth.AuthClient client = auth.authenticatedClient(http.Client(), cred);
  SheetsApi api = new SheetsApi(client);
  ValueRange vr = new ValueRange.fromJson({
    "values": [
      [ // fields A - J
        "15/02/2019", "via API 3", "5", "3", "3", "3", "3", "3", "3", "3"
      ]
    ]
  });
  print('about to append');
  api.spreadsheets.values
      .append(vr, '1cl...spreadsheet_key...W5E', 'A:J',
          valueInputOption: 'USER_ENTERED')
      .then((AppendValuesResponse r) {
    print('append completed.');
    client.close();
  });
  print('called append()');
});
print('ended?');

}

like image 26
Michael Davies Avatar answered Oct 02 '22 22:10

Michael Davies


There's a dart 3rd party library that helps to perform basic operations https://pub.dev/packages/gsheets.

You can also use official library https://pub.dartlang.org/packages/googleapis that helps to perform almost any operation, but it's more difficult to use and sometimes requires knowledge of the API https://developers.google.com/sheets/api/reference/rest

like image 37
Alexander Marenkov Avatar answered Oct 02 '22 23:10

Alexander Marenkov