helpers library

Classes

Debouncer
Throttler
TSimpleOperation
A class representing a simple arithmetic operation with two operands and one operator.

Constants

kEpsilon → const double
kSuperscripts → const Map<String, String>
kSuperscriptsReverse → const Map<String, String>

Properties

isAndroid bool
no setter
isFuchsia bool
no setter
isIOS bool
no setter
isLinux bool
no setter
isMacOS bool
no setter
isWeb bool
no setter
isWindows bool
no setter
supportedLocales List<String>
Getter for supported locales.
no setter

Functions

applyOperation(String operator, List<double> values) → void
Applies the given operator to the top two values in the values stack.
areRouteBasesDifferent(List<RouteBase> routes1, List<RouteBase> routes2) bool
Compares two lists of RouteBase to determine if they are different.
calculatePercentageDecrease(double originalValue, double newValue) double
Calculates the percentage decrease between an originalValue and a newValue.
convertMonthsToYearsAndMonths(int months) Map<String, int>
createDateFormatter(String locale, bool showTime, bool use24HourFormat) → DateFormat
Creates a date formatter based on the locale and preferences.
darkenColor(Color color, double amount) Color
Darkens a given color by a certain amount using the HSL color model.
debounce(Function func, Duration delay) Function
debugLog(String message, {String? debugLabel, dynamic value, bool silent = false}) → void
Function that prints a debug message to the console if the app is running in debug mode.
evaluateExpression(String expression) double
Evaluates an arithmetic expression and returns the result as a double.
formatCurrency({num? value, String? locale = 'en_US', String symbol = 'USD', int? minimumFractionDigits, int? maximumFractionDigits}) String
Formats a value as a currency string using the given localeand symbol. minimumFractionDigits and maximumFractionDigits can be used to specify the minimum and maximum number of decimal places to display.
formatCurrencyPair({required String base, required String counter, String? delimiter}) String
Formats a currency pair using a base and counter currency, and optionally includes a delimiter.
formatDateTime(DateTime dateTime, {bool use24HourFormat = false, String languageCode = 'en', bool showTime = true, String? countryCode}) Future<String>
Formats a DateTime object into a string.
formatDecimal({num? value, String? locale = 'en_US', String? pattern = "#,##0.##", int? minimumFractionDigits, int? maximumFractionDigits}) String
Formats a value as a decimal string using the given locale and pattern. minimumFractionDigits and maximumFractionDigits can be used to specify the minimum and maximum number of decimal places to display.
formatNumberForClipboard(num? value, {int maxFractionDigits = 2}) String
Formats a number for clipboard copying. Handles integers and floats, returning a string with appropriate decimal precision.
formatPercentage({num? value, String? locale = 'en_US', String? pattern = "#,##0.##", int? minimumFractionDigits, int? maximumFractionDigits}) String
Formats a value as a percentage string using the given locale and pattern. minimumFractionDigits and maximumFractionDigits can be used to specify the minimum and maximum number of decimal places to display.
formatPercentageForClipboard(num? value, {int maxFractionDigits = 2}) String
Formats a numeric value into a percentage string suitable for clipboard operations.
formatTimestampInMilliseconds({required int timestamp, bool use24HourFormat = false, String languageCode = 'en', bool showTime = true, String? countryCode, bool isUtc = false}) Future<String>
Formats a timestamp in milliseconds since epoch into a date string.
getCurrencyNumberFormat({num? value, String? locale = 'en_US', String symbol = 'USD', int? minimumFractionDigits, int? maximumFractionDigits}) → NumberFormat
Returns a NumberFormat for currency that uses the locale, symbol, and specific fraction digits defined by the user.
getCurrencySymbol({String? localeCode, String? currencyCode = 'USD'}) String
getDecimalNumberFormat({num? value, String? locale = 'en_US', String? pattern = "#,##0.##", int? minimumFractionDigits, int? maximumFractionDigits}) → NumberFormat
Returns a NumberFormat for decimal numbers that uses the locale, pattern, and specific fraction digits defined by the user.
getDefaultFractionDigits(num? value, int? minimumFractionDigits, int? maximumFractionDigits) → (int, int)
Retrieves the default minimum and maximum fraction digits based on the provided value.
getLastChar(String value, {bool trim = true}) String
Returns the last character of a given string after trimming it if specified.
getRandomItem<T>(List<T> list) → T?
getValue<T>(T? value, {T? defaultValue, bool loose = true}) → T?
isCharDigit(String char) bool
Returns true if char represents a digit, false otherwise.
isCharDigitOrDecimalPoint(String char) bool
Returns true if char represents a digit or a decimal point, false otherwise.
isCharDigitOrDecimalPointOrPercentage(String s) bool
isDoubleInteger(double number, {int? epsilonExponent}) bool
Checks if the input number is a "double integer", i.e., a double value that represents an integer value. Returns true if the input number is a double integer, false otherwise.
isNegativeUnaryOperator(String expression, int index) bool
isNumberInteger(num number, {int? epsilonExponent}) bool
Checks if the input number is an integer. Returns true if the input number is an integer, false otherwise.
isOperator(String s) bool
Returns true if s represents an arithmetic operator, false otherwise.
isStringNumber(String str) bool
Returns true if str represents a valid number, false otherwise.
isStringPercentage(String str) bool
Returns true if the given str is a string representation of a percentage, false otherwise.
isSuperscript(String character) bool
Checks if the given character is a superscript character.
isValidUrl(String input) bool
lightenColor(Color color, double amount) Color
Lightens a given color by a certain amount using the HSL color model.
looseValue<T>(T? value) → T?
nearlyEqual(num a, num b, {int? epsilonExponent}) bool
noop() → void
A no-operation function that does nothing.
parseSimpleOperation(String expression) TSimpleOperation?
Parses a simple mathematical operation expression and returns a TSimpleOperation object that represents the operation.
precedence(String operator) int
Returns an integer representing the precedence level of the given operator.
rangeAroundN(double n, int x, {bool loose = false}) List<num>
removeDiacriticsAndLowercase(String text) String
Removes diacritics (accents) from the given text and then converts it to lowercase.
retrieveDateFormatter({bool use24HourFormat = false, String languageCode = 'en', bool showTime = true, String? countryCode}) Future<DateFormat>
Retrieves a DateFormat object based on locale and preferences.
retry<T>({required Future<T> task(), int maxAttempts = 3, bool validate(T result)?, Duration initialDelay = const Duration(seconds: 1), Duration? maxDelay, Duration? taskTimeout}) Future<T>
Retries a given asynchronous function task for a specified number of maxAttempts with an exponential backoff delay.
revertSuperscripts(String value) String
Reverts superscript characters in the given value to their normal equivalents.
scientificNotationValue(int exponent) double
superscriptLastCharacter(String value) String
Replaces the last character of the given value with its superscript equivalent if available.
throttle(Function func, Duration delay) Function
toCamelCase(String? input) String
Converts a string input to camel case format.
toIos3166Code(String languageCode, {String? countryCode}) String?
Converts a language code and an optional country code to an ISO 3166 code.
toPascalCase(String? input) String
Converts a string input to pascal case format.
toSnakeCase(String input) String
Converts input string to snake_case.
toTitleCase(String? input) String
Converts a string input to title case format.
transformTo2DArray<T>(List<T> array, int columns) List<List<T>>
Transforms a flat list into a 2D list with the given number of columns.