flutter_multi_formatter library Null safety

Classes

CardSystem
CardSystemData
CreditCardCvcInputFormatter
CreditCardExpirationDateFormatter
CreditCardNumberInputFormatter
ForceUnfocuser
ForceUnfocuserRenderBox
IgnoreUnfocuser
IgnoreUnfocuserRenderBox
MaskedInputFormatter
MoneyInputFormatter
MoneySymbols
PhoneCodes
PhoneCountryData
PhoneInputFormatter
Unfocuser
minScrollDistance if you do not want Unfocuser to remove current focus on scroll, set this value as you prefer. By default it's set to 10 pixels this means that if you touch the screen and drag more that 10 pixels it will be considered as scrolling and unfocuser will not trigger In case you want it to always unfocus current text field just set this value to 0.0

Extensions

NumericInputFormatting
WARNING! This stuff requires Dart SDK version 2.6+ so if your code is supposed to be running on older versions do not use these methods! or change the sdk restrictions in your pubspec.yaml like this: environment: sdk: ">=2.6.0 <3.0.0"
StringInputFormatting

Functions

checkMask(String mask) → void
formatAsCardNumber(String cardNumber, {bool useSeparators = true}) String
formatAsPhoneNumber(String phone, {InvalidPhoneAction invalidPhoneAction = InvalidPhoneAction.ShowUnformatted, bool allowEndlessPhone = false, String? defaultMask}) String?
allowEndlessPhone if this is true, the
getCardSystemData(String cardNumber) CardSystemData?
getCountryDatasByPhone(String phone) List<PhoneCountryData>
returns a list of country datas with a country code of the supplied phone number. The return type is List because many countries and territories may share the same phone code the list will contain one PhoneCountryData at max returns A list of PhoneCountryData datas or an empty list
isCardValidNumber(String cardNumber, {bool checkLength = false}) bool
checks not only for length and characters but also for card system code code. If it's not found the succession of numbers will not be marked as a valid card number
isDigit(String? character) bool
isPhoneValid(String phone, {bool allowEndlessPhone = false}) bool
isUnmaskableSymbol(String? symbol) bool
toCurrencyString(String value, {int mantissaLength = 2, ThousandSeparator thousandSeparator = ThousandSeparator.Comma, ShorteningPolicy shorteningPolicy = ShorteningPolicy.NoShortening, String leadingSymbol = '', String trailingSymbol = '', bool useSymbolPadding = false}) String
thousandSeparator specifies what symbol will be used to separate each block of 3 digits, e.g. ThousandSeparator.Comma will format a million as 1,000,000 shorteningPolicy is used to round values using K for thousands, M for millions and B for billions ShorteningPolicy.NoShortening displays a value of 1234456789.34 as 1,234,456,789.34 but ShorteningPolicy.RoundToThousands displays the same value as 1,234,456K mantissaLength specifies how many digits will be added after a period sign leadingSymbol any symbol (except for the ones that contain digits) the will be added in front of the resulting string. E.g. $ or € some of the signs are available via constants like MoneySymbols.EURO_SIGN but you can basically add any string instead of it. The main rule is that the string must not contain digits, preiods, commas and dashes trailingSymbol is the same as leading but this symbol will be added at the end of your resulting string like 1,250€ instead of €1,250 useSymbolPadding adds a space between the number and trailing / leading symbols like 1,250€ -> 1,250 € or €1,250€ -> € 1,250
toNumericString(String? inputString, {bool allowPeriod = false, bool allowHyphen = true}) String

Enums

InvalidPhoneAction
this is used in a formatAsPhoneNumber() function and this is what the returned result depends on
ShorteningPolicy
ThousandSeparator
Comma means this format 1,000,000.00 Period means thousands and mantissa will look like this 1.000.000,00 None no separator will be applied at all SpaceAndPeriodMantissa 1 000 000.00 SpaceAndCommaMantissa 1 000 000,00