Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PORT Firebase x Flutter

shogo.yamada
June 26, 2019
350

PORT Firebase x Flutter

shogo.yamada

June 26, 2019
Tweet

Transcript

  1. FlutterʹFirebase͸࢖͑Δͷ͔ ࢖͍৺஍͸΄΅Web൛Firebase Future<void> postMessage(String groupId, String uid, String message, int

    type) async { return await Firestore.instance .collection("group") .document(groupId) .collection("message") .add({ "uid": uid, "message": message, "type": type, "created_at": FieldValue.serverTimestamp(), }); }
  2. FirestoreͱFlutterͷ૬ੑʹ͍ͭͯ child: StreamBuilder( stream: chatHelper .getMessages(widget.groupId) .asBroadcastStream(), builder: (context, snapshot)

    { if (snapshot == null || snapshot.data == null) return Container(); return new ListView.builder( padding: new EdgeInsets.all(8.0), reverse: true, itemBuilder: (_, int index) { // ͜͜ͰϝοηʔδΛදࣔ͢Δ }, itemCount: snapshot.data.documents.length, ); })