diff --git a/lib/entities/qr_scanner.dart b/lib/entities/qr_scanner.dart index 311bc498aa..d8f7032d36 100644 --- a/lib/entities/qr_scanner.dart +++ b/lib/entities/qr_scanner.dart @@ -23,7 +23,7 @@ Future presentQRScanner(BuildContext context) async { ), ); isQrScannerShown = false; - return result??''; + return result!; } catch (e) { isQrScannerShown = false; rethrow; @@ -95,9 +95,7 @@ class _BarcodeScannerSimpleState extends State { setState(() { popped = true; }); - SchedulerBinding.instance.addPostFrameCallback((_) { - Navigator.of(context).pop(_barcode?.rawValue ?? ""); - }); + Navigator.of(context).pop(_barcode!.rawValue ?? _barcode!.rawBytes); } } } diff --git a/lib/src/screens/nodes/widgets/node_form.dart b/lib/src/screens/nodes/widgets/node_form.dart index 74daa41cce..22a38f4238 100644 --- a/lib/src/screens/nodes/widgets/node_form.dart +++ b/lib/src/screens/nodes/widgets/node_form.dart @@ -58,6 +58,12 @@ class NodeForm extends StatelessWidget { } }); + reaction((_) => nodeViewModel.path, (String path) { + if (path != _pathController.text) { + _pathController.text = path; + } + }); + _addressController.addListener(() => nodeViewModel.address = _addressController.text); _pathController.addListener(() => nodeViewModel.path = _pathController.text); _portController.addListener(() => nodeViewModel.port = _portController.text); diff --git a/lib/view_model/node_list/node_create_or_edit_view_model.dart b/lib/view_model/node_list/node_create_or_edit_view_model.dart index 8b3c70c5e6..9b03b8cc4b 100644 --- a/lib/view_model/node_list/node_create_or_edit_view_model.dart +++ b/lib/view_model/node_list/node_create_or_edit_view_model.dart @@ -219,23 +219,22 @@ abstract class NodeCreateOrEditViewModelBase with Store { throw Exception('Unexpected scan QR code value: value is empty'); } - final uri = Uri.tryParse(code); - - if (uri == null) { - throw Exception('Unexpected scan QR code value: Value is invalid'); - } + if (!code.contains('://')) code = 'tcp://$code'; - final userInfo = uri.userInfo.split(':'); - - if (userInfo.length < 2) { - throw Exception('Unexpected scan QR code value: Value is invalid'); + final uri = Uri.tryParse(code); + if (uri == null || uri.host.isEmpty) { + throw Exception('Invalid QR code: Unable to parse or missing host.'); } - final rpcUser = userInfo[0]; - final rpcPassword = userInfo[1]; + final userInfo = uri.userInfo; final ipAddress = uri.host; - final port = uri.port.toString(); + final port = uri.hasPort ? uri.port.toString() : ''; final path = uri.path; + final queryParams = uri.queryParameters; // Currently not used + final rpcUser = userInfo.split(':').first; + final rpcPassword = userInfo.split(':').length > 1 ? userInfo.split(':')[1] : ''; + + await Future.delayed(Duration(milliseconds: 345)); setAddress(ipAddress); setPath(path);