utils/multi_formatter/flutter_multi_formatter library

Enums

InvalidPhoneAction
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

Extensions

NumericInputFormatting on num
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 on String

Functions

checkMask(String mask) → void
checkNumberByLuhn({required String number}) bool
formatAsCardNumber(String cardNumber) String
formatAsPhoneNumber(String phone, {InvalidPhoneAction invalidPhoneAction = InvalidPhoneAction.ShowUnformatted, bool allowEndlessPhone = false, String? defaultMask, String? defaultCountryCode}) 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
isCardNumberValid({required String cardNumber, bool checkLength = false, bool useLuhnAlgo = true}) bool
useLuhnAlgo validates the number using the Luhn algorithm
isCardValidNumber(String cardNumber, {bool checkLength = false}) bool
checks not only for a length and characters but also for card system code. If it's not found the succession of numbers will not be marked as a valid card number
isCryptoCurrency(String currencyId) bool
Basically it doesn't really check if the currencyId is a crypto currency. It just checks if it's not fiat. I decided not to collect all possible crypto currecies as there's an endless amount of them
isDigit(String? character, {bool positiveOnly = false}) bool
character a character to check if it's a digit against positiveOnly if true it will not allow a minus (dash) character to be accepted as a part of a digit
isFiatCurrency(String currencyId) bool
Checks if currency is fiat
isPhoneValid(String phone, {bool allowEndlessPhone = false, String? defaultCountryCode}) bool
isUnmaskableSymbol(String? symbol) bool
numericStringStartsWithOrphanPeriod(String string) bool
toCurrencyString(String value, {int mantissaLength = 2, ThousandSeparator thousandSeparator = ThousandSeparator.Comma, ShorteningPolicy shorteningPolicy = ShorteningPolicy.NoShortening, String leadingSymbol = '', String trailingSymbol = '', bool useSymbolPadding = false, bool isRawValue = false}) String
isRawValue pass true if you
toNumericString(String? inputString, {bool allowPeriod = false, bool allowHyphen = true, String mantissaSeparator = '.', String? errorText, bool allowAllZeroes = false, int? mantissaLength}) String
errorText if you don't want this method to throw any errors, pass null here allowAllZeroes might be useful e.g. for phone masks
toNumericStringByRegex(String? inputString, {bool allowPeriod = false, bool allowHyphen = true}) String