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
- Inheritance
-
- Object
- ChangeNotifier
- ValueNotifier<
TextEditingValue> - TextEditingController
- CurrencyTextFieldController
Constructors
- CurrencyTextFieldController({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})
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 withR$ 10,00
text.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selection ↔ TextSelection
-
The currently selected 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}) → void - Force a value to the text controller.
-
isSelectionWithinTextBounds(
TextSelection selection) → bool -
Check that the
selection
is inside of the bounds of text.inherited -
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. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited