NumberUtils extension

on

Properties

isDouble bool
Returns true if the number is a double, false otherwise.
no setter
isEven bool
Returns true if the number is even, false otherwise.
no setter
isInteger bool
Returns true if the number is an integer, false otherwise.
no setter
isNegative bool
Returns true if the number is negative, false otherwise.
no setter
isOdd bool
Returns true if the number is odd, false otherwise.
no setter
isPositive bool
Returns true if the number is positive, false otherwise.
no setter
isZero bool
Returns true if the number is zero, false otherwise.
no setter

Methods

contains(num substring) bool
Check if the number contains substring. Returns true if the number contains substring, false otherwise.
count(num substring) int
Get count of a substring in the number. Returns the count of substring in the number.
digitsAfter(num substring) num
Get the digits after a substring in the number Returns the digits after a substring in the number
digitsAfterFirst(num substring) num
Get the digits after the first occurrence of substring in the number Returns the digits after the first occurrence of substring in the number
digitsAfterLast(num substring) num
Get the digits after the last occurrence of substring in the number Returns the digits after the last occurrence of substring in the number
digitsBefore(num substring) num
Get the digits before a substring in the number Returns the digits before a substring in the number
digitsBeforeFirst(num substring) num
Get the digits before the first occurrence of substring in the number Returns the digits before the first occurrence of substring in the number
digitsBeforeLast(num substring) num
Get the digits before the last occurrence of substring in the number Returns the digits before the last occurrence of substring in the number
digitsBetween(num start, num end) num
Get the digits between start and end in the number Returns the digits between start and end in the number
endsWith(num suffix) bool
Check if the number ends with suffix. Returns true if the number ends with suffix, false otherwise.
indexesOf(num substring) List<int>
get the index of all occurrences of substring in the number.
indexOfFirst(num substring) int
Get the index of the first occurrence of substring in the number.
indexOfLast(num substring) int
Get the index of the last occurrence of substring in the number. Returns the index of the last occurrence of substring in the number.
isInRange(num min, num max) bool
Check if the number is in the range min to max. Returns true if the number is in the range, false otherwise.
loremIpsum() String
Get the lorem ipsum text of this words.
randomList({int min = 0, int max = 100}) List<num>
Get list of random numbers.
startsWith(num prefix) bool
Check if the number starts with prefix. Returns true if the number starts with prefix, false otherwise.
sumOfDigits() num
sum of digits Returns the sum of digits in the number.
swapSign() num
Swap the sign of the number.
toCurrencyString([String delimiter = ',', int precision = 2]) String
Convert to currency string with specified delimiter and precision. If delimiter is not specified, the default is ','. If precision is not specified, the default is 2.
toPrecision([int precision = 2]) String
Convert the number to a String with the specified precision. If precision is not specified, the default is 2.