Skip to content

Commit 650befb

Browse files
authored
Handle null result with qr code scanner (#1021)
1 parent fccbe7f commit 650befb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

dogfooding/lib/screens/home_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ class _JoinForm extends StatelessWidget {
418418
onPressed: () async {
419419
final result = await QrCodeScanner.scan(context);
420420

421-
if (context.mounted) {
421+
if (context.mounted && result != null) {
422422
_handleJoinUrl(context, result);
423423
}
424424
},

dogfooding/lib/screens/qr_code_scanner.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class QrCodeScanner extends StatefulWidget {
1313
@override
1414
State<QrCodeScanner> createState() => _QrCodeScannerState();
1515

16-
static Future<String> scan(BuildContext context) async {
16+
static Future<String?> scan(BuildContext context) async {
1717
final result = await Navigator.push(
1818
context,
1919
MaterialPageRoute<String>(builder: (_) => const QrCodeScanner()),
2020
);
21-
return result!;
21+
return result;
2222
}
2323
}
2424

0 commit comments

Comments
 (0)