CurrencyTextFieldController class

A custom TextEditingController for currency input.

currencySymbol is your currency symbol.

Default: R\$

decimalSymbol is the decimal separator symbol.

Default: ,

thousandSymbol is the thousand separator symbol.

@Default: .

initDoubleValue is the optional initial value in double format.

Default: null

initIntValue is the optional initial value in int format. It'll be divided by 100 before being presented.

Default: null

numberOfDecimals lets you define the max number of decimal digits to be presented.

Default: 2

maxDigits lets you define the max number of digits to be presented.

Default: 15

currencyOnLeft lets you define if the symbol will be on left or right of the value.

Default: true

enableNegative lets you define if the user can set negative values.

Default: true

currencySeparator lets you define the separator between the symbol and the value.

Default: ' '

maxValue lets you define the maximum allowed value of the controller.

Default: null

minValue lets you define the minimum allowed value of the controller.

Default: null

startWithSeparator lets you define if the controller starts with decimals activated.

Default: true

showZeroValue lets you define if the controller will show the 0 value.

Default: false

forceCursorToEnd lets you define if the controller will always force the user to input the numbers on the end of the string.

Default: true

removeSymbol lets you define that controller will only show the formatted number.

Default: false

Inheritance

Constructors

CurrencyTextFieldController.new({String currencySymbol = 'R\$', String decimalSymbol = ',', String thousandSymbol = '.', String currencySeparator = ' ', double? initDoubleValue, int? initIntValue, int maxDigits = 15, int numberOfDecimals = 2, bool currencyOnLeft = true, bool enableNegative = true, double? maxValue, double? minValue, bool startWithSeparator = true, bool showZeroValue = false, bool forceCursorToEnd = true, bool removeSymbol = false})

Properties

currencySymbol String
return the currency Symbol of the controller.
no setter
decimalSymbol String
return the decimal Symbol of the controller.
no setter
doubleTextWithoutCurrencySymbol String
return the number part of the controller as a String, formatted as a double (with . as decimal separator).
no setter
doubleValue double
return the number part of the controller as a double.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
intValue int
return the number part of the controller as a int. Ex: 1000 for a controller with R$ 10,00 text.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selection TextSelection
The currently selected range within text.
getter/setter pairinherited
text String
The current string the user is editing.
getter/setter pairinherited
textWithoutCurrencySymbol String
return the number part of the controller as a String.
no setter
thousandSymbol String
return the thousand Symbol of the controller.
no setter
value TextEditingValue
The current value stored in this notifier.
getter/setter pairinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
buildTextSpan({required BuildContext context, TextStyle? style, required bool withComposing}) TextSpan
Builds TextSpan from current editing value.
inherited
checkNegative() bool
check if the value is negative.
clear() → void
Set the value to empty.
inherited
clearComposing() → void
Set the composing region to an empty range.
inherited
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
override
forceValue({double? initDoubleValue, int? initIntValue, bool init = false}) → void
Force a value to the text controller. If initDoubleValue and initIntValue are both null, 0 will be forced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
replaceCurrencySymbol(String newSymbol, {bool resetValue = false}) → void
Replace the current currency symbol by the defined value. If resetValue = true the controller will be reseted to 0.
replaceMaxValue(double newMaxvalue, {bool resetValue = false}) → void
function to replace current maxValue.
replaceMinValue(double newMinvalue, {bool resetValue = false}) → void
function to replace current minValue.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited