Integer class

A wrapper class for int that provides Java-like functionality and methods.

This class wraps Dart's primitive int type and provides additional utility methods similar to Java's Integer class, making it easier for Java developers to work with integers in Dart.

Example usage:

Integer a = Integer(42);
Integer b = Integer.valueOf(10);
Integer c = Integer.parseInt("123");

print(a.toString()); // "42"
print(a.compareTo(b)); // 1 (since 42 > 10)
print(Integer.max(a.value, b.value)); // 42
Implemented types

Constructors

Integer(int _value)
Creates an Integer with the specified value.
const

Properties

hashCode int
Returns the hash code for this Integer.
no setteroverride
isEven bool
Returns true if the value is even.
no setter
isNegative bool
Returns true if the value is negative.
no setter
isOdd bool
Returns true if the value is odd.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value int
Returns the wrapped integer value.
no setter

Methods

abs() Integer
Returns the absolute value of this Integer.
compareTo(Integer other) int
Compares this Integer with another Integer.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDouble() double
Returns the value as a double.
toRadixString([int? radix]) String
Returns a string representation in the specified radix.
toString() String
Returns a string representation of this Integer.
override

Operators

operator %(Integer other) Integer
operator &(Integer other) Integer
Bitwise operators
operator *(Integer other) Integer
operator +(Integer other) Integer
Arithmetic operators
operator -(Integer other) Integer
operator <(Integer other) bool
Comparison operators
operator <<(int shiftAmount) Integer
operator <=(Integer other) bool
operator ==(Object other) bool
Returns true if this Integer equals the specified object.
override
operator >(Integer other) bool
operator >=(Integer other) bool
operator >>(int shiftAmount) Integer
operator ^(Integer other) Integer
operator unary-() Integer
operator |(Integer other) Integer
operator ~() Integer
operator ~/(Integer other) Integer

Static Methods

max(int a, int b) int
Returns the larger of two int values.
min(int a, int b) int
Returns the smaller of two int values.
parseInt(String str, [int radix = 10]) Integer
Creates an Integer from a string representation.
valueOf(int value) Integer
Returns an Integer instance representing the specified int value.
valueOfString(String str, [int radix = 10]) Integer
Returns an Integer instance from a string.

Constants

MAX_VALUE → const int
Maximum value for a 32-bit signed integer
MIN_VALUE → const int
Minimum value for a 32-bit signed integer