-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
140 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
org.gradle.jvmargs=-Xmx1536M | ||
android.useAndroidX=true | ||
android.enableJetifier=true | ||
dev.steenbakker.mobile_scanner.useUnbundled=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:mobile_scanner/mobile_scanner.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
|
||
class QrCodeScanner extends StatefulWidget { | ||
const QrCodeScanner({super.key}); | ||
|
||
@override | ||
State<QrCodeScanner> createState() => _QrCodeScannerState(); | ||
} | ||
|
||
class _QrCodeScannerState extends State<QrCodeScanner> { | ||
bool done = false; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final loc = AppLocalizations.of(context)!; | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text(loc.fieldWebsiteQR), | ||
), | ||
body: MobileScanner( | ||
onDetect: (codes) { | ||
if (!done && mounted && codes.barcodes.isNotEmpty) { | ||
final code = codes.barcodes.first; | ||
String? url; | ||
if (code.type == BarcodeType.url) { | ||
url = code.url?.url; | ||
} else if (code.type == BarcodeType.text || | ||
code.type == BarcodeType.unknown) { | ||
final value = code.displayValue; | ||
if (value != null && value.startsWith("http")) { | ||
url = value; | ||
} | ||
} | ||
|
||
if (url != null) { | ||
done = true; // we need this because it scans twice sometimes | ||
Navigator.pop(context, url); | ||
} | ||
} | ||
}, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters