This file contains 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
signUp(String emailID, String password) async { | |
try { | |
await FirebaseAuth.instance | |
.createUserWithEmailAndPassword(email: emailID, password: password); | |
debugPrint("Logged in successfully!"); | |
} on FirebaseAuthException catch (e) { | |
switch (e.code) { | |
case 'weak-password': | |
debugPrint('The password provided is too weak.'); | |
break; |
This file contains 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
StreamBuilder( | |
stream: FirebaseAuth.instance.authStateChanges(), | |
builder: (context, snapshot) { | |
if (snapshot.hasData) { | |
return const MyHomePage(); | |
} else { | |
return const LoginPage(); | |
} | |
}, | |
) |
This file contains 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
Future<void> printDoc() async { | |
final doc = pw.Document(); | |
doc.addPage(pw.Page( | |
pageFormat: PdfPageFormat.a4, | |
build: (pw.Context context) { | |
return pw.Center( | |
child: pw.Text('Hello World'), | |
); | |
})); | |
await Printing.layoutPdf( |
This file contains 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
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: const Text("Printer Demo"), | |
), | |
body: Center( | |
child: ElevatedButton( | |
onPressed: () { | |
printDoc(); | |
}, |
This file contains 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
Future<void> printDoc() async { | |
final doc = pw.Document(); | |
doc.addPage(pw.Page( | |
pageFormat: PdfPageFormat.a4, | |
build: (pw.Context context) { | |
return [...] // Any Flutter widget | |
})); | |
await Printing.layoutPdf( | |
onLayout: (PdfPageFormat format) async => doc.save()); | |
} |
This file contains 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
Future<void> downloadURLExample() async { | |
downloadURL = await FirebaseStorage.instance | |
.ref() | |
.child("Flutter.png") | |
.getDownloadURL(); | |
} |
This file contains 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
Future<void> main() async { | |
WidgetsFlutterBinding.ensureInitialized(); | |
await Firebase.initializeApp(); | |
runApp(const MyApp()); | |
} |
This file contains 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
<body> | |
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js"></script> | |
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-storage.js"></script> | |
<script> | |
const firebaseConfig = { | |
apiKey: "xxxxxxxxx", | |
authDomain: "xxxxxxxxx", | |
projectId: "xxxxxxxxx", | |
storageBucket: "xxxxxxxxx", | |
messagingSenderId: "xxxxxxxxx", |
This file contains 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
Widget buildShimmerItems() => ListView.separated( | |
padding: const EdgeInsets.all(8), | |
itemCount: 10, | |
separatorBuilder: (BuildContext context, int index) => const Divider(), | |
itemBuilder: (BuildContext context, int index) { | |
return const ShimmerWidget(); | |
}); |
This file contains 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
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: const Text("Firebase Demo"), | |
), | |
body: FutureBuilder( | |
future: FireStoreDataBase().getData(), | |
builder: (context, snapshot) { | |
if (snapshot.hasError) { |