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)
Title of the "contains text" rule.
final
digit → String Function(int length)
Title of the number rule for count digits.
final
email → String
Title of the email format rule.
final
emailField → String
Labels of RegexTextField.password, .email and .userName.
final
endsWith → String Function(String text)
Title of the "ends with text" rule.
final
exactLength → String Function(int length)
Title of the exact length rule, e.g. "Exactly 6 characters".
final
hashCode → int
The hash code for this object.
no setterinherited
hide → String
Show / hide password button.
final
iban → String
Title of the IBAN rule.
final
join → String Function(List<String> words)
Joins character names into one phrase: "letters, numbers and _".
final
lengthBetween → String Function(int min, int max)
Title of the length range rule, e.g. "8 to 20 characters".
final
lowercase → String Function(int length)
Title of the lowercase letter rule for count letters.
final
maxLength → String Function(int length)
Title of the maximum length rule, e.g. "At most 20 characters".
final
met → String
Screen reader words for a met / not met rule.
final
minLength → String Function(int length)
Title of the minimum length rule, e.g. "At least 8 characters".
final
none → String Function(String text)
Title of notAllowed; list is built by join.
final
noRepeating → String Function(int length)
Title of the "no character repeated more than count times in a row" rule.
final
noSpaces → String
Title of the no-spaces rule.
final
notContains → String
Title of the "doesn't contain" rule.
final
notStartsWith → String Function(String text)
Title of the "doesn't start with text" rule.
final
only → String Function(String text)
Title of allowOnly and the "only" rules; list is built by join.
final
passwordField → String
Labels of RegexTextField.password, .email and .userName.
final
phone → String
Title of the phone number rule.
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
Title of the "same as the other field" rule (password repeat).
final
show → String
Show / hide password button.
final
space → String
Name of a space passed in allow:.
final
special → String Function(int length)
Title of the special character rule for count characters.
final
startsWith → String Function(String text)
Title of the "starts with text" rule.
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)
Title of the uppercase letter rule for count letters.
final
url → String
Title of the web address rule.
final
userNameField → String
Labels of RegexTextField.password, .email and .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; chars entries 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
German labels.
en → const RegexLabels
English labels (the default).
es → const RegexLabels
Spanish labels.
fr → const RegexLabels
French labels.
it → const RegexLabels
Italian labels.
ja → const RegexLabels
Japanese labels.
pt → const RegexLabels
Portuguese labels.
tr → const RegexLabels
Turkish labels.