Skip to content

Instantly share code, notes, and snippets.

View vijayinyoutube's full-sized avatar
👋
vijaycreations

Vijay R vijayinyoutube

👋
vijaycreations
View GitHub Profile
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;
StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return const MyHomePage();
} else {
return const LoginPage();
}
},
)
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(
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Printer Demo"),
),
body: Center(
child: ElevatedButton(
onPressed: () {
printDoc();
},
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());
}
Future<void> downloadURLExample() async {
downloadURL = await FirebaseStorage.instance
.ref()
.child("Flutter.png")
.getDownloadURL();
}
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(const MyApp());
}
<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",
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();
});
@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) {