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

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

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

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

Masaya Nasu

April 02, 2018
Tweet

More Decks by Masaya Nasu

Other Decks in Technology

Transcript

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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