RegexLabels class
Every text regex_ui writes by itself: rule titles, RegexChar names, screen reader words, strength labels and field labels.
Set your language once, before the rules are built (e.g. in main).
Pass only what you change; the rest stays English:
RegexLabels.current = RegexLabels(
minLength: (n) => '$n文字以上',
chars: {RegexChar.whitespace: 'スペース', RegexChar.digits: '数字'},
only: (list) => '$listのみ',
join: (words) => words.join('、'),
);
Ready languages: en, tr, de, es, fr, it, pt, ja:
RegexLabels.current = RegexLabels.tr; or, from the device language,
RegexLabels.forLanguage(locale.languageCode). Change a few words of a
ready language with copyWith.
One rule only? Pass title: to that rule instead.
Constructors
-
RegexLabels({String minLength(int length) = _minLength, String maxLength(int length) = _maxLength, String lengthBetween(int min, int max) = _lengthBetween, String exactLength(int length) = _exactLength, String uppercase(int length) = _uppercase, String lowercase(int length) = _lowercase, String digit(int length) = _digit, String special(int length) = _special, String noRepeating(int length) = _noRepeating, String startsWith(String text) = _startsWith, String notStartsWith(String text) = _notStartsWith, String endsWith(String text) = _endsWith, String contains(String text) = _contains, String only(String text) = _only, String none(String text) = _none, String join(List<
String> words) = _join, Map<RegexChar, String> chars = const {}, String space = 'spaces', String noSpaces = 'No spaces', String email = 'Valid e-mail address', String phone = 'Valid phone number', String url = 'Valid web address', String iban = 'Valid IBAN', String sameAs = 'Passwords must match', String required = 'Required', String notContains = 'Does not contain your name', String met = 'met', String unmet = 'not met', List<String> strength = const ['Very weak', 'Weak', 'Fair', 'Good', 'Strong'], String show = 'Show password', String hide = 'Hide password', String passwordField = 'Password', String emailField = 'E-mail', String userNameField = 'User name'}) -
Creates labels; anything left out stays English.
const
Properties
-
chars
→ Map<
RegexChar, String> -
Names of the RegexChar groups you want to change; the others keep
their English name.
final
- contains → String Function(String text)
-
final
- digit → String Function(int length)
-
final
- email → String
-
final
- emailField → String
-
Labels of
RegexTextField.password,.emailand.userName.final - endsWith → String Function(String text)
-
final
- exactLength → String Function(int length)
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hide → String
-
Show / hide password button.
final
- iban → String
-
final
-
join
→ String Function(List<
String> words) -
Joins character names into one phrase: "letters, numbers and _".
final
- lengthBetween → String Function(int min, int max)
-
final
- lowercase → String Function(int length)
-
final
- maxLength → String Function(int length)
-
final
- met → String
-
Screen reader words for a met / not met rule.
final
- minLength → String Function(int length)
-
final
- none → String Function(String text)
-
Title of
notAllowed;listis built by join.final - noRepeating → String Function(int length)
-
final
- noSpaces → String
-
final
- notContains → String
-
final
- notStartsWith → String Function(String text)
-
final
- only → String Function(String text)
-
Title of
allowOnlyand the "only" rules;listis built by join.final - passwordField → String
-
Labels of
RegexTextField.password,.emailand.userName.final - phone → String
-
final
- required → String
-
Form error of an empty field (the checklist shows the rules instead).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sameAs → String
-
final
- show → String
-
Show / hide password button.
final
- space → String
-
Name of a space passed in
allow:.final - special → String Function(int length)
-
final
- startsWith → String Function(String text)
-
final
-
strength
→ List<
String> -
Password strength words, weakest first.
final
- unmet → String
-
Screen reader words for a met / not met rule.
final
- uppercase → String Function(int length)
-
final
- url → String
-
final
- userNameField → String
-
Labels of
RegexTextField.password,.emailand.userName.final
Methods
-
char(
RegexChar char) → String -
Name of
char: yours from chars, or the English one. -
copyWith(
{String minLength(int length)?, String maxLength(int length)?, String lengthBetween(int min, int max)?, String exactLength(int length)?, String uppercase(int length)?, String lowercase(int length)?, String digit(int length)?, String special(int length)?, String noRepeating(int length)?, String startsWith(String text)?, String notStartsWith(String text)?, String endsWith(String text)?, String contains(String text)?, String only(String text)?, String none(String text)?, String join(List< String> words)?, Map<RegexChar, String> ? chars, String? space, String? noSpaces, String? email, String? phone, String? url, String? iban, String? sameAs, String? required, String? notContains, String? met, String? unmet, List<String> ? strength, String? show, String? hide, String? passwordField, String? emailField, String? userNameField}) → RegexLabels -
A copy with the given texts changed;
charsentries are merged. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- current ↔ RegexLabels
-
The labels used by every rule and widget. English by default.
getter/setter pair
Static Methods
-
forLanguage(
String languageCode) → RegexLabels -
The ready labels for
languageCode(e.g. "tr", "ja-JP"), English when that language is not built in.
Constants
-
builtIn
→ const Map<
String, RegexLabels> - Ready languages by language code.
- de → const RegexLabels
- en → const RegexLabels
- es → const RegexLabels
- fr → const RegexLabels
- it → const RegexLabels
- ja → const RegexLabels
- pt → const RegexLabels
- tr → const RegexLabels