TurkishMoneyInputMask class

As-you-type formatting for a Turkish money field: 1.234,56 (with an optional ₺ suffix), without depending on Flutter.

apply takes the text before and after an edit and returns the formatted text with the cursor where the user expects it:

  • digits typed or deleted anywhere keep the cursor next to them, even when thousands separators appear or disappear;
  • backspace (or delete) on a . separator or on the symbol removes the digit next to it instead of doing nothing;
  • , starts the decimals; a . typed on its own is also taken as the decimal separator, because many numeric keyboards only have a dot;
  • pasted text may be 1234.56, 1.234,56, ₺1.234,56, 1 234,56 TL and similar;
  • edits that would exceed fractionDigits or maxValue are rejected (the old value is kept); typing - toggles the sign when allowNegative.

Numbers are grouped and parsed with the same rules as TurkishMoney and TurkishNumberFormat. For Flutter, use TurkishMoneyInputFormatter from the turkish_kit_flutter package, or wrap apply in a TextInputFormatter yourself.

Constructors

TurkishMoneyInputMask({int fractionDigits = 2, TurkishMoney? maxValue, bool allowNegative = false, String symbol = ''})
Creates a mask.
const

Properties

allowNegative → bool
Whether negative amounts can be entered.
final
fractionDigits → int
The number of decimals that can be entered (0-2).
final
hashCode → int
The hash code for this object.
no setteroverride
maxValue → TurkishMoney?
The largest absolute amount that can be entered, or null for no limit.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
suffix → String
The text shown after the number: ' ₺', or '' without a symbol.
no setter
symbol → String
The currency symbol shown after the number, or ''.
final

Methods

apply(TurkishEditValue oldValue, TurkishEditValue newValue) → TurkishEditValue
The formatted result of changing oldValue into newValue. The returned selection is collapsed (a cursor). Returns oldValue unchanged if the edit is not allowed.
complete(String text) → String
text in its final form: decimals padded (1.234,5 → 1.234,50), an incomplete - or , cleared. Call it when the field loses focus.
format(TurkishMoney? money) → String
money as the field shows it: '1.234,50 ₺'; '' for null.
maxCursor(String text) → int
The last offset the cursor may take in text (before the suffix).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse(String text) → TurkishMoney?
The amount in text, or null if it is empty or incomplete ('-'). Accepts the field's own format and anything TurkishMoney.parse does.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
override