Flutter upgrade

This commit is contained in:
M
2022-10-12 13:09:57 -04:00
parent c921ad890a
commit 1beb18b045
505 changed files with 6657 additions and 5875 deletions
+12 -12
View File
@@ -1,13 +1,13 @@
import 'package:flutter/foundation.dart';
abstract class Validator<T> {
Validator({@required this.errorMessage});
Validator({required this.errorMessage});
final String errorMessage;
bool isValid(T value);
bool isValid(T? value);
String call(T value) => !isValid(value) ? errorMessage : null;
String? call(T? value) => !isValid(value) ? errorMessage : null;
}
class TextValidator extends Validator<String> {
@@ -15,28 +15,28 @@ class TextValidator extends Validator<String> {
{this.minLength,
this.maxLength,
this.pattern,
String errorMessage = '',
this.length,
this.isAutovalidate = false,
String errorMessage})
this.isAutovalidate = false})
: super(errorMessage: errorMessage);
final int minLength;
final int maxLength;
final List<int> length;
final int? minLength;
final int? maxLength;
final List<int>? length;
final bool isAutovalidate;
String pattern;
String? pattern;
@override
bool isValid(String value) {
bool isValid(String? value) {
if (value == null || value.isEmpty) {
return isAutovalidate ? true : false;
}
return value.length > (minLength ?? 0) &&
(length?.contains(value.length) ?? true) &&
((maxLength ?? 0) > 0 ? (value.length <= maxLength) : true) &&
((maxLength ?? 0) > 0 ? (value.length <= maxLength!) : true) &&
(pattern != null ? match(value) : true);
}
bool match(String value) => RegExp(pattern).hasMatch(value);
bool match(String value) => pattern != null ? RegExp(pattern!).hasMatch(value) : false;
}