scanQRBabyBeat method
- String barcodeScanRes
Scans the QR code for the BabyBeat organization.
barcodeScanRes
is the scanned QR code result.
Implementation
Future<void> scanQRBabyBeat(String barcodeScanRes) async {
setState(() => isEditOrgBB = false);
if (barcodeScanRes != "-1" && barcodeScanRes.isNotEmpty) {
try {
Map<String, dynamic> mapHospital = jsonDecode(barcodeScanRes);
if (mapHospital['type'] == "babybeat") {
final doc = await databases.getDocument(
databaseId: 'your_database_id',
collectionId: 'users',
documentId: mapHospital['hospitalId'],
);
final dbPartner = doc.data;
if (dbPartner['documentId'] == mapHospital['hospitalId']) {
_enterMPIDBottomSheetBabyBeat(
mapHospital['hospitalId'], mapHospital['hospitalName']);
} else {
_showError('Something went wrong!');
}
} else {
_showError('Invalid QR CODE');
}
} catch (_) {
_showError('Invalid QR CODE');
}
}
}