mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-02 19:26:37 +00:00
allow empty address forms in contact address form validation
This commit is contained in:
parent
f04018dbe6
commit
bd72f65fc9
2 changed files with 26 additions and 4 deletions
|
@ -33,6 +33,19 @@ class AddressEntryData extends ChangeNotifier {
|
|||
notifyListeners();
|
||||
}
|
||||
|
||||
bool get isEmpty {
|
||||
if (address != null && address!.isNotEmpty) {
|
||||
return false;
|
||||
}
|
||||
if (addressLabel != null && addressLabel!.isNotEmpty) {
|
||||
return false;
|
||||
}
|
||||
if (coin != null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get isValid {
|
||||
if (_address == null || coin == null || _addressLabel == null) {
|
||||
return false;
|
||||
|
|
|
@ -5,10 +5,19 @@ final validContactStateProvider =
|
|||
StateProvider.autoDispose.family<bool, List<int>>((ref, ids) {
|
||||
bool isValid = true;
|
||||
|
||||
bool hasAtLeastOneValid = false;
|
||||
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
isValid = isValid &&
|
||||
ref.watch(
|
||||
addressEntryDataProvider(ids[i]).select((value) => value.isValid));
|
||||
final _valid = ref.watch(
|
||||
addressEntryDataProvider(ids[i]).select((value) => value.isValid));
|
||||
|
||||
final _isEmpty = ref.watch(
|
||||
addressEntryDataProvider(ids[i]).select((value) => value.isEmpty));
|
||||
|
||||
isValid = isValid && (_valid || _isEmpty);
|
||||
if (_valid) {
|
||||
hasAtLeastOneValid = true;
|
||||
}
|
||||
}
|
||||
return isValid;
|
||||
return isValid && hasAtLeastOneValid;
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue