mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 13:05:11 +00:00
fix: Scan qr code breaks app
This commit is contained in:
parent
c7a020a71b
commit
31f844da4d
2 changed files with 7 additions and 5 deletions
|
@ -75,7 +75,9 @@ class NewPrivateChatController extends State<NewPrivateChat> {
|
|||
}
|
||||
await showAdaptiveBottomSheet(
|
||||
context: context,
|
||||
builder: (_) => const QrScannerModal(),
|
||||
builder: (_) => QrScannerModal(
|
||||
onScan: (link) => UrlLauncher(context, link).openMatrixToUrl(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,10 +6,9 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:qr_code_scanner/qr_code_scanner.dart';
|
||||
|
||||
import 'package:fluffychat/utils/url_launcher.dart';
|
||||
|
||||
class QrScannerModal extends StatefulWidget {
|
||||
const QrScannerModal({super.key});
|
||||
final void Function(String) onScan;
|
||||
const QrScannerModal({required this.onScan, super.key});
|
||||
|
||||
@override
|
||||
QrScannerModalState createState() => QrScannerModalState();
|
||||
|
@ -69,7 +68,8 @@ class QrScannerModalState extends State<QrScannerModal> {
|
|||
sub = controller.scannedDataStream.listen((scanData) {
|
||||
sub.cancel();
|
||||
Navigator.of(context).pop();
|
||||
UrlLauncher(context, scanData.code).openMatrixToUrl();
|
||||
final data = scanData.code;
|
||||
if (data != null) widget.onScan(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue