Created
March 15, 2022 20:20
-
-
Save romanejaquez/29c26e7b1968343d9ce834f8c70032ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:google_fonts/google_fonts.dart'; | |
import 'package:firebase_core/firebase_core.dart'; | |
import 'package:cloud_firestore/cloud_firestore.dart'; | |
void main() async { | |
WidgetsFlutterBinding.ensureInitialized(); | |
await Firebase.initializeApp( | |
options: const FirebaseOptions( | |
apiKey: "AIzaSyA6H1jOIFt9e7V4h_CrlcGXzk0px36g_XM", | |
authDomain: "gdg-community-app-c5120.firebaseapp.com", | |
projectId: "gdg-community-app-c5120", | |
storageBucket: "gdg-community-app-c5120.appspot.com", | |
messagingSenderId: "884593610503", | |
appId: "1:884593610503:web:436620635a564cc32e3fa2" | |
) | |
); | |
runApp(HomeApp()); | |
} | |
class HomeApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
textTheme: GoogleFonts.poppinsTextTheme( | |
Theme.of(context).textTheme | |
) | |
), | |
home: HomePage() | |
); | |
} | |
} | |
class HomePage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: StreamBuilder( | |
stream: FirebaseFirestore.instance.collection('sample').doc('first').snapshots(), | |
builder: (context, snapshot) { | |
if (snapshot.hasData && (snapshot.data as DocumentSnapshot).exists) { | |
Map<String, dynamic> docData = (snapshot.data as DocumentSnapshot).data() as Map<String, dynamic>; | |
return Text(docData['value'].toString()); | |
} | |
return Text('does not exist!'); | |
} | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment