File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
views/wallets_manager/widgets Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -99,11 +99,23 @@ class WalletsRepository {
9999 getWallets ().ignore ();
100100 return null ;
101101 }
102+
103+ final trimmedName = name.trim ();
104+
105+ // Check if the trimmed name is empty (prevents space-only names)
106+ if (trimmedName.isEmpty) {
107+ return LocaleKeys .walletCreationNameLengthError.tr ();
108+ }
109+
110+ // Check if trimmed name exceeds length limit
111+ if (trimmedName.length > 40 ) {
112+ return LocaleKeys .walletCreationNameLengthError.tr ();
113+ }
102114
115+ // Check for duplicates using the exact input name (not trimmed)
116+ // This preserves backward compatibility with existing wallets that might have spaces
103117 if (_cachedWallets! .firstWhereOrNull ((w) => w.name == name) != null ) {
104118 return LocaleKeys .walletCreationExistNameError.tr ();
105- } else if (name.isEmpty || name.length > 40 ) {
106- return LocaleKeys .walletCreationNameLengthError.tr ();
107119 }
108120
109121 return null ;
Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ class _WalletCreationState extends State<WalletCreation> {
186186
187187 WidgetsBinding .instance.addPostFrameCallback ((timeStamp) {
188188 widget.onCreate (
189- name: _nameController.text,
189+ name: _nameController.text. trim () ,
190190 password: _passwordController.text,
191191 walletType: _isHdMode ? WalletType .hdwallet : WalletType .iguana,
192192 );
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ class _WalletImportWrapperState extends State<WalletSimpleImport> {
9797 _step == WalletSimpleImportSteps .nameAndSeed
9898 ? LocaleKeys .walletImportTitle.tr ()
9999 : LocaleKeys .walletImportCreatePasswordTitle.tr (
100- args: [_nameController.text],
100+ args: [_nameController.text. trim () ],
101101 ),
102102 style: Theme .of (
103103 context,
@@ -325,7 +325,7 @@ class _WalletImportWrapperState extends State<WalletSimpleImport> {
325325
326326 WidgetsBinding .instance.addPostFrameCallback ((_) {
327327 widget.onImport (
328- name: _nameController.text,
328+ name: _nameController.text. trim () ,
329329 password: _passwordController.text,
330330 walletConfig: config,
331331 );
You can’t perform that action at this time.
0 commit comments