NumberExtensions extension

Extensions for int operations and utilities.

on

Properties

absValue int

Available on int, provided by the NumberExtensions extension

Returns the absolute value of the number.
no setter
days Duration

Available on int, provided by the NumberExtensions extension

Converts days to a Duration.
no setter
hours Duration

Available on int, provided by the NumberExtensions extension

Converts hours to a Duration.
no setter
isEven bool

Available on int, provided by the NumberExtensions extension

Returns true if the number is even.
no setter
isNegative bool

Available on int, provided by the NumberExtensions extension

Returns true if the number is negative (less than 0).
no setter
isOdd bool

Available on int, provided by the NumberExtensions extension

Returns true if the number is odd.
no setter
isPositive bool

Available on int, provided by the NumberExtensions extension

Returns true if the number is positive (greater than 0).
no setter
isZero bool

Available on int, provided by the NumberExtensions extension

Returns true if the number is zero.
no setter
minutes Duration

Available on int, provided by the NumberExtensions extension

Converts minutes to a Duration.
no setter
seconds Duration

Available on int, provided by the NumberExtensions extension

Converts seconds to a Duration.
no setter

Methods

clampTo(int min, int max) int

Available on int, provided by the NumberExtensions extension

Clamps the number between min and max.
format({String? prefix, String? suffix}) String

Available on int, provided by the NumberExtensions extension

Formats the number as a string with optional prefix and suffix.
formatCurrency({String symbol = '\$', int decimals = 2}) String

Available on int, provided by the NumberExtensions extension

Formats the number as currency.
formatWithSeparator({String separator = ','}) String

Available on int, provided by the NumberExtensions extension

Formats the number with thousand separators.
isBetween(int min, int max) bool

Available on int, provided by the NumberExtensions extension

Returns true if the number is between min and max (inclusive).
rangeTo(int end) List<int>

Available on int, provided by the NumberExtensions extension

Returns a list of integers from this number to end (exclusive).
rangeToInclusive(int end) List<int>

Available on int, provided by the NumberExtensions extension

Returns a list of integers from this number to end (inclusive).
toHumanReadable({int decimals = 1}) String

Available on int, provided by the NumberExtensions extension

Converts the number to a human-readable string (e.g., 1K, 1M).