From 16c6640d9cf94781e881c20a1d9012d374ce7176 Mon Sep 17 00:00:00 2001 From: WaseemAbbasi22 Date: Tue, 29 Oct 2024 11:21:11 +0300 Subject: [PATCH] bug fixes --- .../views/components/get_qr_code_view.dart | 67 +++++++++++++++++++ .../views/components/history_log_view.dart | 1 + 2 files changed, 68 insertions(+) create mode 100644 lib/service_request_latest/views/components/get_qr_code_view.dart diff --git a/lib/service_request_latest/views/components/get_qr_code_view.dart b/lib/service_request_latest/views/components/get_qr_code_view.dart new file mode 100644 index 00000000..ff0586ac --- /dev/null +++ b/lib/service_request_latest/views/components/get_qr_code_view.dart @@ -0,0 +1,67 @@ +import 'package:flutter/material.dart'; + +class GetQRCodeView extends StatelessWidget { + final String qrCodeUrl = "https://your-qrcode-url.com/qrcode.png"; // Replace with your QR code URL + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('QR Code Dialog Example'), + ), + body: Center( + child: ElevatedButton( + onPressed: () { + showQRCodeDialog(context, qrCodeUrl); + }, + child: Text('Show QR Code'), + ), + ), + ); + } + + // Function to display the QR code in a dialog + void showQRCodeDialog(BuildContext context, String qrCodeUrl) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('Scan QR Code'), + content: Image.network( + qrCodeUrl, + loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) { + if (loadingProgress == null) { + return child; // Display the QR code once loaded + } else { + // Show a CircularProgressIndicator while the image is loading + return Center( + child: CircularProgressIndicator( + value: loadingProgress.expectedTotalBytes != null + ? loadingProgress.cumulativeBytesLoaded / (loadingProgress.expectedTotalBytes ?? 1) + : null, + ), + ); + } + }, + errorBuilder: (context, error, stackTrace) { + // Display an error widget if the image fails to load + return Icon(Icons.error, color: Colors.red); + }, + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); // Close the dialog + }, + child: Text('Close'), + ), + ], + ); + }, + ); + } +} + +void main() { + runApp(MaterialApp(home: GetQRCodeView())); +} diff --git a/lib/service_request_latest/views/components/history_log_view.dart b/lib/service_request_latest/views/components/history_log_view.dart index 8dd19ba9..092b7640 100644 --- a/lib/service_request_latest/views/components/history_log_view.dart +++ b/lib/service_request_latest/views/components/history_log_view.dart @@ -95,6 +95,7 @@ class HistoryLogView extends StatelessWidget { ).expanded, Expanded( flex: 2, + //.... child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [