High-level interfaces to Google Cloud Platform APIs

Related tags

Animation gcloud
Overview

Google Cloud Platform support package (gcloud)

The gcloud package provides a high level "idiomatic Dart" interface to some of the most widely used Google Cloud Platform services. Currently the following services are supported:

  • Cloud Datastore
  • Cloud Storage
  • Cloud Pub/Sub

The APIs in this package are all based on the generic generated APIs in the googleapis and googleapis_beta packages.

This means that the authentication model for using the APIs in this package uses the googleapis_auth package.

Note that this package is only intended for being used with the standalone VM in a server or command line application. Don't expect this package to work on the browser or in Flutter.

The code snippets below demonstrating the use of this package all assume that the following imports are present:

import 'dart:io';
import 'package:googleapis_auth/auth_io.dart' as auth;
import 'package:http/http.dart' as http;
import 'package:gcloud/db.dart';
import 'package:gcloud/storage.dart';
import 'package:gcloud/pubsub.dart';
import 'package:gcloud/service_scope.dart' as ss;
import 'package:gcloud/datastore.dart' as datastore;

Getting access to the APIs

The first step in using the APIs is to get an authenticated HTTP client and with that create API class instances for accessing the different APIs. The code below assumes that you have a Google Cloud Project called my-project with credentials for a service account from that project stored in the file my-project.json.

// Read the service account credentials from the file.
var jsonCredentials = new File('my-project.json').readAsStringSync();
var credentials = new auth.ServiceAccountCredentials.fromJson(jsonCredentials);

// Get an HTTP authenticated client using the service account credentials.
var scopes = []
    ..addAll(datastore.Datastore.Scopes)
    ..addAll(Storage.SCOPES)
    ..addAll(PubSub.SCOPES);
var client = await auth.clientViaServiceAccount(credentials, scopes);

// Instantiate objects to access Cloud Datastore, Cloud Storage
// and Cloud Pub/Sub APIs.
var db = new DatastoreDB(
    new datastore.Datastore(client, 's~my-project'));
var storage = new Storage(client, 'my-project');
var pubsub = new PubSub(client, 'my-project');

All the APIs in this package supports the use of 'service scopes'. Service scopes are described in details below.

ss.fork(() {
  // register the services in the new service scope.
  registerDbService(db);
  registerStorageService(storage);
  registerPubSubService(pubsub);

  // Run application using these services.
});

The services registered with the service scope can now be reached from within all the code running in the same service scope using the below getters.

dbService.
storageService.
pubsubService.

This way it is not necessary to pass the service objects around in your code.

Use with App Engine

The gcloud package is also integrated in the Dart appengine package. This means the gcloud services are available both via the appengine context and service scopes. The authentication required to access the Google Cloud Platform services is handled automatically.

This means that getting to the App Engine Datastore can be through either the App Engine context

var db = context.services.db;

or just using the service scope registration.

var db = dbService;

Cloud Datastore

Google Cloud Datastore provide a NoSQL, schemaless database for storing non-relational data. See the product page https://cloud.google.com/datastore/ for more information.

The Cloud Datastore API provides a mapping of Dart objects to entities stored in the Datastore. The following example shows how to annotate a class to make it possible to store instances of it in the Datastore.

@db.Kind()
class Person extends db.Model {
  @db.StringProperty()
  String name;

  @db.IntProperty()
  int age;
}

The Kind annotation tell that instances of this class can be stored. The class must also inherit from Model. Now to store an object into the Datastore create an instance and use the commit function.

var person = new Person()
    ..name = ''
    ..age = 42;
await db.commit(inserts: [person]);

The function query is used to build a Query object which can be run to perform the query.

var persons = (await db.query<Person>().run()).toList();

To fetch one or multiple existing entities, use lookup.

var key = new Person()
    ..name = 'UniqueName'
    ..age = 42
    ..parentKey = db.emptyKey;
var person = (await db.lookup<Person>([key])).single;
var people = await db.lookup<Person>([key1, key2]);

NOTE: This package include a lower level API provided through the class Datastore on top of which the DatastoreDB API is build. The main reason for this additional API level is to bridge the gap between the different APIs exposed inside App Engine and through the public REST API. We reserve the rights to modify and maybe even remove this additional layer at any time.

Cloud Storage

Google Cloud Storage provide a highly available object store (aka BLOB store). See the product page https://cloud.google.com/storage/ for more information.

In Cloud Storage the objects (BLOBs) are organized in buckets. Each bucket has a name in a global namespace. The following code creates a new bucket named my-bucket and writes the content of the file my-file.txt to the object named my-object.

var bucket = await storage.createBucket('my-bucket');
new File('my-file.txt').openRead().pipe(bucket.write('my-object'));

The following code will read back the object.

bucket.read('my-object').pipe(new File('my-file-copy.txt').openWrite());

Cloud Pub/Sub

Google Cloud Pub/Sub provides many-to-many, asynchronous messaging. See the product page https://cloud.google.com/pubsub/ for more information.

Cloud Pub/Sub uses two concepts for messaging. Topics are used if you want to send messages and subscriptions are used to subscribe to topics and receive the messages. This decouples the producer of a message from the consumer of a message.

The following code creates a topic and sends a simple test message:

var topic = await pubsub.createTopic('my-topic');
await topic.publishString('Hello, world!')

With the following code a subscription is created on the topic and a message is pulled using the subscription. A received message must be acknowledged when the consumer has processed it.

var subscription =
    await pubsub.createSubscription('my-subscription', 'my-topic');
var pullEvent = await subscription.pull();
print(pullEvent.message.asString);
await pullEvent.acknowledge();

It is also possible to receive messages using push events instead of pulling from the subscription. To do this the subscription should be configured as a push subscription with an HTTP endpoint.

await pubsub.createSubscription(
    'my-subscription',
    'my-topic',
    endpoint: Uri.parse('https://server.example.com/push'));

With this subscription all messages will be send to the URL provided in the endpoint argument. The server needs to acknowledge the reception of the message with a 200 OK reply.

Running tests

If you want to run the end-to-end tests, a Google Cloud project is required. When running these tests the following environment variables need to be set:

GCLOUD_E2E_TEST_PROJECT

The value of the environment variable GCLOUD_E2E_TEST_PROJECT is the name of the Google Cloud project to use. Authentication for testing uses Application Default Credentials locally you can provide GOOGLE_APPLICATION_CREDENTIALS or use gcloud auth application-default login.

You will also need to create indexes as follows:

gcloud --project "$GCLOUD_E2E_TEST_PROJECT" datastore indexes create test/index.yaml
Comments
  • Add generics support for queries and lookups

    Add generics support for queries and lookups

    This is a breaking change that supports generics which makes it easier to be used with dart 2.0

    // Before
    db.query(Person).run(); // -> Stream<Model>
    // After
    db.query<Person>().run(); // -> Stream<Person>
    
    // Before
    db.lookup([key]); // -> Future<List<Model>>
    // After
    db.lookup<Person>([key]); // -> Future<List<Person>>
    

    Closes #54

    cla: yes 
    opened by enyo 10
  • Getting a Content size exceeds specified contentLength. error when after upgrading to v0.8.6

    Getting a Content size exceeds specified contentLength. error when after upgrading to v0.8.6

    After upgrading to v0.8.6, I start getting this error. 0.8.5 works without any errors

      Future<String> uploadFile(File file, String fileName) async {
        // https://console.cloud.google.com/apis/dashboard storage needs to be enabled
    
        fileName = '${Uuid().v4()}-$fileName'.replaceAll(' ', '_');
        await file.openRead().pipe(bucket.write(fileName));
        return fileName;
      }
    
      Content size ex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XVuYXV0aGVudGljYXRlZGBg]
      package:http/src/io_client.dart 90:7                         IOClient.send
      ===== asynchronous gap ===========================
      package:googleapis_auth/src/auth_http_utils.dart 36:22       AuthenticatedClient.send
      ===== asynchronous gap ===========================
      package:_discoveryapis_commons/src/api_requester.dart 69:20  ApiRequester.request
      ===== asynchronous gap ===========================
      package:googleapis/storage/v1.dart 2765:23                   ObjectsResource.insert
      ===== asynchronous gap ===========================
      package:gcloud/src/storage_impl.dart 640:15                  _MediaUploadStreamSink._startNormalUpload.<fn>
      
    

    The example here https://github.com/bettdouglas/firestore_proxy has a simple reproducible example. Seems like there was a new bug introduced with the upgrade to googleapis.

    bug 
    opened by bettdouglas 7
  • Update googleapis package to latest version

    Update googleapis package to latest version

    Package googleapis released a new version 6.0.0 to fix some null safety issue.

    Our app flutter/cocoon needs the above version to unblock some cron job APIs (https://github.com/flutter/flutter/issues/90019). However, we are relying on gcloud package as well. Currently we are using ^0.8.2, which depends on googleapis >=3.0.0 <6.0.0, causing confict.

    This PR points googleapis version to the latest release 6.0.0.

    cla: yes 
    opened by keyonghan 5
  • Is this library compatible with flutter?

    Is this library compatible with flutter?

    I have tried to implement this library with a flutter project and got the below errors:

    E/flutter ( 1549): [ERROR:flutter/shell/common/shell.cc(178)] Dart Error: error: import of dart:mirrors is not supported in the current Dart runtime
    E/flutter ( 1549): [ERROR:flutter/shell/common/engine.cc(188)] Could not prepare to run the isolate.
    E/flutter ( 1549): [ERROR:flutter/shell/common/engine.cc(127)] Engine not prepare and launch isolate.
    E/flutter ( 1549): [ERROR:flutter/shell/common/shell.cc(407)] Could not launch engine with configuration.
    

    My pubspec.yaml file:

    dependencies:
      flutter:
        sdk: flutter
    
      cupertino_icons: ^0.1.2
      gcloud: ^0.6.3
    

    Even though googleapis_auth is already present in dev_dependencies of gcloud package still when I tried to import 'package:googleapis_auth/auth_io.dart' as auth; it gives me the following error: Target of URI doesn't exist: 'package:googleapis_auth/auth_io.dart'.

    opened by DhavalRKansara 5
  • Added defaultValue to Property

    Added defaultValue to Property

    This is based on top of https://github.com/dart-lang/gcloud/pull/81 so feel free to ignore the first commit. It was just necessary for tests to have a change at passing.

    cla: yes 
    opened by jonasfj 5
  • Add generics support

    Add generics support

    With dart 2.0 this package is a bit inconvenient to use, because queries always return a generic Stream<Model> instead of the requested model. This results in lots of code like this:

    final query = db.query(models.Page)
      ..filter('isPublished =', true);
    return query.run().cast<models.Page>();
    

    Ideally gcloud would support generics like this:

    final query db.query<models.Page>()
      ..filter('isPublished =', true);
    return query.run(); // <-- Stream<models.Page>
    
    opened by enyo 4
  • Records not immediately available after committing

    Records not immediately available after committing

    I have this code that deletes all the records of a Kind, commits a new Model of that kind, and finally returns all the models of that kind.

    evento = new Evento ();
    
    Help.ClearAllOfKind(Evento) //Clears all the recods
                .then (evento.Put) //Commit the model 'evento'
                .then((_) => new Future.delayed(new Duration(milliseconds: 10))) //Delay to test if time is an issue
                .then (Help.AllF (Evento)); //Return all records of Kind Evento
    

    The problem is that it clears all the records, but the new commit doesn't appear for a while and db.commit apparently completes before the whole DB is updated, so the last future that returns all records outputs an empty list. If I set a long enough delay I do get a list with the committed evento;

    Edit Is this behavior expected? Does commit try to insert immediately or are queries somehow queued to avoid multiple round trips?

    opened by cgarciae 4
  • Datastore query throws exception when querying an entity that has a double property of 1.0

    Datastore query throws exception when querying an entity that has a double property of 1.0

    Hello, i am using gcloud's datastore library and stumble into a strange problem. When i query on an entity that has a double value property without precision (ie 1.00, 2.00) , the following exception is thrown.

    Unhandled exception:
    type 'int' is not a subtype of type 'double' of 'value' where
      int is from dart:core
      double is from dart:core
    
    #0      Value.doubleValue= (package:googleapis/datastore/v1.dart:1870:15)
    #1      Value.Value.fromJson (package:googleapis/datastore/v1.dart:1927:7)
    #2      Entity.Entity.fromJson.<anonymous closure> (package:googleapis/datastore/v1.dart:614:70)
    #3      mapMap.<anonymous closure> (package:_discoveryapis_commons/src/clients.dart:916:28)
    #4      _HashVMBase&MapMixin&&_LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:348)
    #5      mapMap (package:_discoveryapis_commons/src/clients.dart:911:10)
    #6      Entity.Entity.fromJson (package:googleapis/datastore/v1.dart:614:20)
    #7      EntityResult.EntityResult.fromJson (package:googleapis/datastore/v1.dart:666:20)
    #8      QueryResultBatch.QueryResultBatch.fromJson.<anonymous closure> (package:googleapis/datastore/v1.dart:1619:65)
    #9      MappedListIterable.elementAt (dart:_internal/iterable.dart:412)
    #10     ListIterable.toList (dart:_internal/iterable.dart:219)
    #11     QueryResultBatch.QueryResultBatch.fromJson (package:googleapis/datastore/v1.dart:1619:95)
    #12     RunQueryResponse.RunQueryResponse.fromJson (package:googleapis/datastore/v1.dart:1822:19)
    #13     ProjectsResourceApi.runQuery.<anonymous closure> (package:googleapis/datastore/v1.dart:307:41)
    #14     _rootRunUnary (dart:async/zone.dart:1158)
    #15     _CustomZone.runUnary (dart:async/zone.dart:1037)
    #16     _FutureListener.handleValue (dart:async/future_impl.dart:131)
    #17     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:637)
    #18     _Future._propagateToListeners (dart:async/future_impl.dart:667)
    #19     _Future._complete (dart:async/future_impl.dart:467)
    #20     Stream.join.<anonymous closure> (dart:async/stream.dart:685)
    #21     _rootRun (dart:async/zone.dart:1146)
    #22     _CustomZone.run (dart:async/zone.dart:1026)
    #23     _CustomZone.runGuarded (dart:async/zone.dart:924)
    #24     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:384)
    #25     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:394)
    #26     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:278)
    #27     _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:95)
    #28     _EventSinkWrapper.close (dart:async/stream_transformers.dart:18)
    #29     _StringAdapterSink.close (dart:convert/string_conversion.dart:267)
    #30     _Utf8ConversionSink.close (dart:convert/string_conversion.dart:324)
    #31     _ConverterStreamEventSink.close (dart:convert/chunked_conversion.dart:96)
    #32     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:140)
    #33     _rootRun (dart:async/zone.dart:1146)
    #34     _CustomZone.run (dart:async/zone.dart:1026)
    #35     _CustomZone.runGuarded (dart:async/zone.dart:924)
    #36     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:384)
    #37     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:394)
    #38     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:278)
    #39     _ForwardingStream._handleDone (dart:async/stream_pipe.dart:116)
    #40     _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:184)
    #41     _rootRun (dart:async/zone.dart:1146)
    #42     _CustomZone.run (dart:async/zone.dart:1026)
    #43     _CustomZone.runGuarded (dart:async/zone.dart:924)
    #44     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:384)
    #45     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:394)
    #46     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:278)
    #47     _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:95)
    #48     _EventSinkWrapper.close (dart:async/stream_transformers.dart:18)
    #49     _ByteAdapterSink.close (dart:convert/byte_conversion.dart:68)
    #50     _FilterSink.close (dart:io/data_transformer.dart:524)
    #51     _ConverterStreamEventSink.close (dart:convert/chunked_conversion.dart:96)
    #52     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:140)
    #53     _rootRun (dart:async/zone.dart:1146)
    #54     _CustomZone.run (dart:async/zone.dart:1026)
    #55     _CustomZone.runGuarded (dart:async/zone.dart:924)
    #56     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:384)
    #57     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:394)
    #58     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:278)
    #59     _ForwardingStream._handleDone (dart:async/stream_pipe.dart:116)
    #60     _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:184)
    #61     _rootRun (dart:async/zone.dart:1146)
    #62     _CustomZone.run (dart:async/zone.dart:1026)
    #63     _CustomZone.runGuarded (dart:async/zone.dart:924)
    #64     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:384)
    #65     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:394)
    #66     _DelayedDone.perform (dart:async/stream_impl.dart:609)
    #67     _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706)
    #68     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:666)
    #69     _rootRun (dart:async/zone.dart:1150)
    #70     _CustomZone.run (dart:async/zone.dart:1026)
    #71     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:953)
    #72     _microtaskLoop (dart:async/schedule_microtask.dart:41)
    #73     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
    #74     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:394)
    #75     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:414)
    #76     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)
    
    
    
    

    I have created an example of the behavior HERE

    opened by avoivo 3
  • [Bug] Error when commiting a ListProperty<ModelKeyPropert> of length 1

    [Bug] Error when commiting a ListProperty of length 1

    I have this minimal code that creates 2 models, commits one (t2), then adds its key to the list of keys of the other (t1) and commits it (t1).

    var t1 = new G()
            ..parentKey = db.emptyKey.append(G, id: 1);
        var t2 = new G()
            ..parentKey = db.emptyKey.append(G, id: 1);
    
       return db.commit(inserts: [t2])
               .then((_) => t1.keySS = [t2.key]) //<=====ERROR IS HERE
               .then((_) => db.commit(inserts: [t1]))
               .then((_) => t1);
    

    Where G is defined as

    @Kind()
    class G extends Model
    {
        @ListProperty(const ModelKeyProperty())
        List<Key> keySS = [];
    }
    

    Now if you just make a little change and add any other key to the list

     t1.keySS = [t2.key, t2.key] //now it works -_-
    

    it now it works.

    The explicit runtime error is

    ApplicationError: Cannot encode unsupported Key type.
    
    package:appengine/src/api_impl/raw_datastore_v3_impl.dart 319:7   Codec.encodeProperty
    package:appengine/src/api_impl/raw_datastore_v3_impl.dart 235:40  Codec.encodeEntity
    package:appengine/src/api_impl/raw_datastore_v3_impl.dart 402:49  DatastoreV3RpcImpl.commit
    package:gcloud/src/db/db.dart 352:29                              _commitHelper
    package:gcloud/src/db/db.dart 319:25                              DatastoreDB.commit
    

    The errors seems to be because there are two Key types -one inside models.dart (the ones we mortals use) and another inside datastore.dart (for datastore demigods)- and in some special case it might not be passing the correct type along the path.

    opened by cgarciae 3
  • Blank screen when importing gcloud/db.dart

    Blank screen when importing gcloud/db.dart

    Whenever I add the db module of the gcloud package to any of my projects, the app just shows a blank screen.

    import 'package:flutter/material.dart';
    import 'package:google_maps_flutter/google_maps_flutter.dart';
    import 'dart:async';
    import 'directions_api.dart';
    import 'package:flutter_polyline_points/flutter_polyline_points.dart';
    import 'dart:convert';
    
    import 'package:gcloud/db.dart' as gcloud; // THIS IMPORT GIVES A BLANK SCREEN
    

    Anyone experience this before?

    EDIT: I tried running flutter clean

    Here are some errors I see in the console:

    E/flutter ( 9559): [ERROR:flutter/shell/common/shell.cc(209)] Dart Error: error: import of dart:mirrors is not supported in the current Dart runtime
    E/flutter ( 9559): [ERROR:flutter/shell/common/engine.cc(205)] Could not prepare to run the isolate.
    E/flutter ( 9559): [ERROR:flutter/shell/common/engine.cc(144)] Engine not prepare and launch isolate.
    E/flutter ( 9559): [ERROR:flutter/shell/common/shell.cc(481)] Could not launch engine with configuration.
    Connecting to VM Service at ws://127.0.0.1:40169/gXoJXnqv7w4=/ws
    W/mple.test_app_( 9559): Reducing the number of considered missed Gc histogram windows from 138 to 100```
    opened by andrelegault 2
  • Not working with built_value library (dev channel)

    Not working with built_value library (dev channel)

    When I execute this command flutter pub run build_runner watch I get the following error Could not find a file named "pubspec.yaml" in "/home/cinderella/development/flutter/.pub-cache/hosted/pub.dartlang.org/gcloud-0.6.3"

    If I remove the gcloud dependency, then it works.

    I'm using it in Dart linux, not Flutter.

    Update - It seems to work well on stable channel

    Flutter doctor

    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel dev, v1.16.1, on Linux, locale en_US.UTF-8)
     
    [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    [✓] Chrome - develop for the web
    [✓] Android Studio (version 3.6)
    [!] IntelliJ IDEA Ultimate Edition (version 2019.3)
        ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    [✓] VS Code (version 1.43.1)
    [✓] Connected device (3 available)
    
    ! Doctor found issues in 1 category.
    

    opened by ghost 2
  • Cloud Storage - character = encoded to %3D on bucket key name

    Cloud Storage - character = encoded to %3D on bucket key name

    So i am encoding to bucket key the object metadata like this: accountantBusinessName=Ing. Monika Frydrychová,accountantBusinessId=86556231/clientBusinessName=Ladislav Zítka,clientBusinessId=74819071/incoming/documentId=fec70948-6a33-4ff5-bb27-ada7f834b283.jpg

    But when written in google cloud storage some of characters are encoded which is bad behavior: accountantBusinessName%3DIng. Monika Frydrychová,accountantBusinessId%3D86556231/clientBusinessName%3DLadislav Zítka,clientBusinessId%3D74819071/incoming/documentId%3Dfec70948-6a33-4ff5-bb27-ada7f834b283.jpg

    Please not that spaces neither accent characters are not encoded, only '=' char.

    Also I have tested for example with Java implementation of google libs and it works good. I suspect something in this dart lib.

    opened by archenroot 1
  • Question: Google service account JSON security

    Question: Google service account JSON security

    Hi,

    its my first flutter app dev, I make images and store them in bucket in google cloud storage. I originally developed cloud run java API which eventually might use keycloack oauth tokens as input from flutter for auth while later it will use google service account. But its slowing down process and I found this plugin as well, so instead I want to use this plugin directly, but how to secure google service account json file in flutter app, so I can load it later into google and apple stores?

    I didn't find any clear answer to this while googling.

    If I do something like device registration process with keycloack, then I can use it to emit short lived tokens for app. This will be the way, but I don't its good practice to store sa json file directly in flutter code...

    Thanks for hints

    opened by archenroot 0
  • Non-nullable model fields

    Non-nullable model fields

    Are there any plans to improve non-nullable fields on Models? Right now, if I'm not mistaken, all fields need to be nullable, so the library can construct them. I think that this should probably be changed, so the constructor accepts all fields as named arguments so that we can access required fields without !.

    opened by enyo 0
  • Cloud Pub Sub Streaming Pull

    Cloud Pub Sub Streaming Pull

    Hi,

    Thank you for the amazing plugin, I hope you don't mind if I ask several questions regarding Cloud Pub/Sub, I am wondering how to get continuous message stream of a topic subscription? Because we are trying to get a real-time stream of messages in a newly created subscription. Using the "pull" method will not listen to the stream of messages asynchronously in a topic subscribed.

    I have tried to double check and found out that the cloud pub/sub actually has the streaming pull method but I think it is still not yet implemented in the newest version of gcloud plugin (is there any plan to accommodate the Streaming Pull like in ),

    Am I doing it the correct way? please correct me if I am wrong

    Warmest Regards Steve

    opened by stevedj 0
  • Subscription is missing

    Subscription is missing "seek" method

    Event though ProjectsSubscriptionsResourceApi has a seek method, it is not exposed on Subscription itself. Is there any way I can actually do a seek then?

    opened by wytrych 0
Releases(0.7.0+1)
Owner
Dart
Dart is an open-source, scalable programming language, with robust libraries and runtimes, for building web, server, and mobile apps.
Dart
💙 Google Classroom Clone using Flutter, GCP

Introduction ?? Classroom is a Google Classroom clone built using ?? Flutter. Before we start, you can take a look at the app: Screenshots ?? Key Feat

Sanjeev Madhav 20 Dec 14, 2022
An advance flutter UI Kit for developing responsive, cross platform applications.

Liquid Build fast, responsive, cross platform apps with Liquid. Liquid is an open source UI toolkit for developing cross platform apps in Flutter. Qui

StackOrient Pvt. Ltd. 29 Dec 9, 2022
High-level APIs for Amazon Web Services (AWS) in Dart

High-level APIs for Amazon Web Services (AWS) in Dart Shared API utilities Generated API packages directory DocumentClient for DynamoDB Code generator

null 178 Dec 28, 2022
Binding and high-level wrapper on top of libssh - The SSH library!

Dart Binding to libssh version 0.9.6 binding and high-level wrapper on top of libssh - The SSH library! libssh is a multiplatform C library implementi

Isaque Neves 2 Dec 20, 2021
A set of high-level Flutter UI components and stand-alone widgets for easier implementation of most used UI features

A set of high-level Flutter UI components and stand-alone widgets for easier implementation of most used UI features

Evgeny Cherkasov 37 Jul 25, 2022
The complete solution for Dart command-line interfaces

The complete solution for Dart command-line interfaces, inspired by node commander.js which created by tj.

Axetroy 6 Feb 21, 2020
Google Cloud Platform support package (gcloud)

Google Cloud Platform support package (gcloud) The gcloud package provides a hig

Behruz Hurramov 0 Dec 28, 2021
Get google api credentials - A Dart CLI app to obtain credentials for accessing Google APIs

get_google_api_credentials A Dart CLI app to obtain credentials for accessing Go

null 1 Jan 28, 2022
A migration of Google Maps Application with Flutter & Google Maps APIs including: Maps SDK for Android & IOS, Places API & polylines

google_maps A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if t

TAD 1 Mar 4, 2022
A mobile client for the public apis repository, 1400+ free apis to use able to be navigated through your phone :)

Public APIs mobile app Your assistant app that will help you discover and pick the next API for your next development project What it contains, you sa

Gwhyyy 4 Dec 25, 2022
Dart, Flutter, Google Cloud, and ranked voting!

Try it out Hosted at https://knarlyvote.com tl;dr A (work-in-progress) demonstration of: (1) a full-stack Flutter application utilizing Firebase and G

Kevin Moore 29 Oct 6, 2022
Dota 2 App using Firebase and Google Cloud

Dota 2 App using Firebase and Google Cloud This is a pet project that born with the idea of having a nice subject to go through some Live Coding sessi

Alvaro Viebrantz 39 Dec 15, 2022
Gcloud-flutter-dota-app - Dota 2 App using Firebase and Google Cloud

Dota 2 App using Firebase and Google Cloud This is a pet project that born with the idea of having a nice subject to go through some Live Coding sessi

Alvaro Viebrantz 39 Dec 15, 2022
A Flutter example to use Google Maps in iOS and Android apps via the embedded Google Maps plugin Google Maps Plugin

maps_demo A Flutter example to use Google Maps in iOS and Android apps via the embedded Google Maps plugin Google Maps Plugin Getting Started Get an A

Gerry High 41 Feb 14, 2022
A note-taking app powered by Google services such as Google Sign In, Google Drive, and Firebase ML Vision.

Smart Notes A note-taking app powered by Google services such as Google Sign In, Google Drive, and Firebase ML Vision. This is an official entry to Fl

Cross Solutions 88 Oct 26, 2022
💖A free IoT (Internet of Things) platform and private cloud

??A free IoT (Internet of Things) platform and private cloud

Open IoT Hub(云易连) 422 Nov 30, 2022
Public interface definitions of Google APIs for Dart and gRPC

Public interface definitions of Google APIs for Dart and gRPC. Getting started I

Mahdi K. Fard 1 Feb 23, 2022
Maps for Flutter developers. Supports Apple, Bing, and Google APIs.

Overview Cross-platform geographic maps for Flutter applications. Pull requests are welcome! The packages are licensed under the Apache License 2.0. P

Dint 17 Oct 13, 2022
SpriteWidget Viktor LidholtSpriteWidget [1143⭐] - Toolkit for building complex, high performance animations and 2D games by Viktor Lidholt.

SpriteWidget SpriteWidget is a toolkit for building complex, high performance animations and 2D games with Flutter. Your sprite render tree lives insi

null 1.2k Dec 7, 2022