codingecho

日々の体験などを書いてます

Use Cloud Functions on Flutter 1.0.0

When you use Cloud Functions on Flutter, you might add some dependencies in pubspec.yaml.

My Flutter app's version
Flutter: 1.0.0

Below is my code uses FutureBuilder.

FutureBuilder(
    future: CloudFunctions.instance.call(functionName: 'hello'),
    builder: (BuildContext context, AsyncSnapshot snapshot) {
      if (snapshot.hasData) {
        if (snapshot.data != null) {
          return new Text(snapshot.data['greeting']);
        }
      }

      return Text('none');
    }
)

You might add cloud_functions and also cloud_firestore. Because if you only add cloud_functions, your Cloud Functions call status ends up "waiting." I searched this happen, but finally, I didn't get the answer. It might be fixed this error in the future.

pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  cloud_functions: ^0.0.5
  cloud_firestore: ^0.8.2+3 # Cloud Functions' depencency might need this depency.