Simplify QR URI validation.

This commit is contained in:
Dain Nilsson 2023-08-18 10:44:24 +02:00
parent f129d415a4
commit 859ad926c4
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8

View File

@ -70,7 +70,8 @@ class _QrScannerViewState extends State<QrScannerView> {
setState(() {
if (qrCodeData.isNotEmpty) {
try {
_validateQrCodeUri(Uri.parse(qrCodeData)); // throws ArgumentError if validation fails
CredentialData.fromUri(Uri.parse(
qrCodeData)); // throws ArgumentError if validation fails
_scannedString = qrCodeData;
_status = ScanStatus.success;
@ -92,18 +93,6 @@ class _QrScannerViewState extends State<QrScannerView> {
});
}
void _validateQrCodeUri(Uri qrCodeUri) {
try {
CredentialData.fromUri(qrCodeUri);
} on ArgumentError catch (_) {
try {
CredentialData.fromMigration(qrCodeUri);
} on ArgumentError catch (_) {
throw ArgumentError();
}
}
}
@override
void initState() {
super.initState();