You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
jeedy20
changed the title
Doesn't work after deploying to firebase
Doesn't work after deploying to firebase. Works of mobile chrome but not on windows browser
Oct 24, 2024
`// ignore_for_file: avoid_print
import 'dart:async';
import 'package:admin/constance.dart';
import 'package:admin/models/currency_formatter.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pw;
import 'package:printing/printing.dart';
import '../models/order_model.dart';
class PdfGeneratorOrderReceipt extends StatefulWidget {
final OrderModel2 orderModel2;
final String fullName;
const PdfGeneratorOrderReceipt({
super.key,
required this.orderModel2,
required this.fullName,
});
@OverRide
State createState() =>
_PdfGeneratorOrderReceiptState();
}
class _PdfGeneratorOrderReceiptState extends State {
@OverRide
initState() {
super.initState();
getCurrencyDetails();
getPhoneDetails();
getAddressDetails();
getBusinessDetails();
getEmailDetails();
// fetchOrders();
}
String userID = '';
String getcurrencySymbol = '';
String businessName = '';
String email = '';
String address = '';
String phone = '';
getCurrencyDetails() {
FirebaseFirestore.instance
.collection('Currency Settings')
.doc('Currency Settings')
.get()
.then((value) {
setState(() {
getcurrencySymbol = value['Currency symbol'];
});
});
}
getPhoneDetails() {
FirebaseFirestore.instance
.collection('Business Details')
.doc('phone')
.snapshots()
.listen((value) {
if (mounted) {
setState(() {
phone = value['phone'];
});
}
});
}
getEmailDetails() {
FirebaseFirestore.instance
.collection('Business Details')
.doc('email')
.snapshots()
.listen((value) {
if (mounted) {
setState(() {
email = value['email'];
});
}
});
}
getBusinessDetails() {
FirebaseFirestore.instance
.collection('Business Details')
.doc('business name')
.snapshots()
.listen((value) {
if (mounted) {
setState(() {
businessName = value['business name'];
});
}
});
}
getAddressDetails() {
FirebaseFirestore.instance
.collection('Business Details')
.doc('address')
.snapshots()
.listen((value) {
if (mounted) {
setState(() {
address = value['address'];
});
}
});
}
@OverRide
Widget build(BuildContext context) {
print('Orders are $getcurrencySymbol');
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
automaticallyImplyLeading: false,
actions: [
Padding(
padding: const EdgeInsets.all(8.0),
child: IconButton(
color: Colors.black,
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(Icons.close)),
)
],
),
body: businessName.isEmpty
? const Center(child: CircularProgressIndicator())
: PdfPreview(
build: (format) => _generatePdf(
format,
'Order Receipt',
widget.orderModel2,
context,
getcurrencySymbol,
widget.fullName,
businessName,
email,
address,
phone),
),
);
}
Future _generatePdf(
PdfPageFormat format,
String title,
OrderModel2 users,
BuildContext context,
String currencySymbol,
String fullname,
String business,
String email,
String address,
String phone,
) async {
final pdf = pw.Document(version: PdfVersion.pdf_1_5, compress: true);
// Load the image from assets
final image = await imageFromAssetBundle(logo);
}
}
`
The text was updated successfully, but these errors were encountered: