Flutterとfirebaseを使ってモバイルアプリに挑戦してみる

 Flutterとfirebaseを使ってモバイルアプリに挑戦してみる

Flutterとfirebaseを使ってモバイルアプリを作ろうとしている話。
サンプルコード
https://github.com/nasum/flutter_firebase_playground

1d42b38276c3d2c7cc931fa444c13488?s=128

Masaya Nasu

April 02, 2018
Tweet

Transcript

  1. 7.
  2. 11.

    firebase auth buildscript { repositories { google() jcenter() } dependencies

    { classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.google.gms:google-services:3.2.0' } } android/build.gradle
  3. 15.

    firebase auth void _handleSignIn() async { GoogleSignInAccount googleUser = await

    _googleSignIn.signIn(); GoogleSignInAuthentication googleAuth = await googleUser.authentication; FirebaseUser siginUser = await _auth.signInWithGoogle( accessToken: googleAuth.accessToken, idToken: googleAuth.idToken, ); setState(() { user = siginUser; }); } lib/main.dart
  4. 16.

    firebase auth if (user != null) { displayName = new

    Text(user.displayName); email = new Text(user.email); avator = new CircleAvatar(backgroundImage: new NetworkImage(user.photoUrl)); } lib/main.dart
  5. 20.

    firebase auth • ඞཁͳϥΠϒϥϦ • google_sign_in
 https://pub.dartlang.org/packages/google_sign_in • firebase_auth
 https://pub.dartlang.org/packages/firebase_auth

    • ίʔυྫ • https://github.com/nasum/flutter_firebase_playground/ commit/66acc51fc6d67258dfb4b0194b3dcac72ff8992a
  6. 25.

    cloud firestore void _getDocument(List<Widget> list) async { QuerySnapshot snapShot =

    await Firestore.instance.collection('memo').getDocuments(); setState(() { snapShot.documents.forEach((DocumentSnapshot ds) { SizedBox box = new SizedBox( width: 300.0, height: 50.0, child: new Card(child: new Text(ds.data['text'])), ); list.add(box); }); }); } lib/main.dart