I32Type class final
32-bit signed integer type (-2,147,483,648 to 2,147,483,647).
Represents signed 32-bit integers for smart contracts. Range: -2,147,483,648 to 2,147,483,647, encoded as 4 bytes with two's complement.
Example
final positive = I32Type.create(1000000);
final negative = I32Type.create(-500000);
final zero = I32Type.create(0);
final max = I32Type.create(2147483647);
print(positive.nativeValue); // 1000000
print(negative.toBytes()); // [255, 248, 113, 192] (two's complement)
print(max.toBytes()); // [127, 255, 255, 255]
// Use in struct definitions
final structType = StructType(
name: 'AccountDelta',
fieldDefinitions: [
FieldDefinition(name: 'balance', type: I32Type.type),
],
);
- Inheritance
-
- Object
- AbiType
- PrimitiveType
- NumericalType
- I32Type
- Available extensions
- Annotations
-
- @immutable
Properties
- cardinality → TypeCardinality
-
Type cardinality.
finalinherited
-
classHierarchy
→ List<
String> -
Returns full class hierarchy from most specific to most general.
no setteroverride
- className → String
-
Returns class name for runtime type identification.
no setteroverride
- firstTypeParameter → AbiType
-
Gets first type parameter.
no setterinherited
- fullyQualifiedName → String
-
Returns fully qualified name including type parameters.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasMetadata → bool
-
Whether type has metadata attached.
no setterinherited
- isDynamic → bool
-
Whether type has dynamic (variable) length.
no setterinherited
- isDynamic → bool
-
Available on AbiType, provided by the AbiTypeExtensions extension
Returns whether the type has dynamic length.no setter - isGeneric → bool
-
Whether type is generic (has type parameters).
no setterinherited
- isSigned → bool
-
Whether this type represents signed integers.
finalinherited
- metadata → dynamic
-
Optional metadata.
finalinherited
- name → String
-
Type name (e.g., 'u32', 'Address', 'List').
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sizeInBytes → int?
-
Returns byte size if fixed, null if dynamic.
finalinherited
-
typeParameters
→ List<
AbiType> -
Type parameters for generic types.
finalinherited
Methods
-
canAcceptValue(
dynamic nativeValue) → bool -
Checks if type can accept the given native value.
inherited
-
createValue(
dynamic nativeValue) → I32Value -
Creates typed value from native Dart value.
override
-
createValueOrThrow<
T extends TypedValue> (dynamic nativeValue) → T -
Available on AbiType, provided by the AbiTypeOrThrowExtensions extension
Creates a TypedValue from native value and ensures it matches expected type. -
equals(
AbiType other) → bool -
Checks type equality based on fully qualified names.
inherited
-
hasClassOrSuperclass(
String name) → bool -
Checks if instance is or extends the specified class.
inherited
-
hasExactClass(
String name) → bool -
Checks if instance is exactly the specified class.
inherited
-
isAssignableFrom(
AbiType other) → bool -
Checks if type can be assigned from
othertype.inherited -
isValidValue(
dynamic value) → bool -
Available on AbiType, provided by the AbiTypeExtensions extension
Checks if the value is valid for this type. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
requireType<
T extends AbiType> (String message) → T -
Available on AbiType, provided by the AbiTypeValidationExtensions extension
Ensures this type is an instance ofT, throwing with a custom message if not. -
toMap(
) → Map< String, dynamic> -
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited