fix: Node Issues (#2498)
- Allow adding new nodes without port - Replace default port number for empty string when there's no port added
David Adegoke committed
Sep 5, 2025 at 14:41 UTC
f0ca065a487a1e60a4d8293a08b1301cfeb64525
3 files changed
+12
-8
lib/core/node_port_validator.dart
+6
-4
@@ -4,8 +4,10 @@ import 'package:cake_wallet/core/validator.dart';
4
class NodePortValidator extends TextValidator {
5
NodePortValidator()
6
: super(
7
- errorMessage: S.current.error_text_node_port,
8
- minLength: 0,
9
- maxLength: 5,
10
- pattern: '^[0-9]');
7
+ errorMessage: S.current.error_text_node_port,
8
+ minLength: 0,
9
+ maxLength: 5,
10
+ pattern: '^[0-9]',
11
+ isAutovalidate: true,
12
+ );
13
}
lib/src/screens/nodes/widgets/node_form.dart
+5
-2
@@ -19,7 +19,10 @@ class NodeForm extends StatelessWidget {
19
this.type,
20
}) : _addressController = TextEditingController(text: editingNode?.uri.host.toString()),
21
_pathController = TextEditingController(text: editingNode?.path.toString()),
22
- _portController = TextEditingController(text: editingNode?.uri.port.toString()),
22
+ _portController = TextEditingController(
23
+ text: (editingNode != null && editingNode.uri.hasPort)
24
+ ? editingNode.uri.port.toString()
25
+ : ''),
26
_loginController = TextEditingController(text: editingNode?.login),
27
_passwordController = TextEditingController(text: editingNode?.password),
28
_socksAddressController = TextEditingController(text: editingNode?.socksProxyAddress) {
@@ -27,7 +30,7 @@ class NodeForm extends StatelessWidget {
30
nodeViewModel
31
..setAddress((editingNode!.uri.host.toString()))
32
..setPath((editingNode!.path.toString()))
30
- ..setPort((editingNode!.uri.port.toString()))
33
+ ..setPort((editingNode!.uri.hasPort ? editingNode!.uri.port.toString() : ''))
34
..setPassword((editingNode!.password ?? ''))
35
..setLogin((editingNode!.login ?? ''))
36
..setSSL((editingNode!.isSSL))
lib/view_model/node_list/node_create_or_edit_view_model.dart
+1
-2
@@ -71,8 +71,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
71
72
@computed
73
bool get isReady =>
74
- (address.isNotEmpty && port.isNotEmpty) ||
75
- _walletType == WalletType.decred; // Allow an empty address.
74
+ (address.isNotEmpty) || _walletType == WalletType.decred; // Allow an empty address.
75
76
bool get hasAuthCredentials =>
77
_walletType == WalletType.monero || _walletType == WalletType.wownero || _walletType == WalletType.haven;