U8Type class final

8-bit unsigned integer type (0 to 255).

Represents unsigned 8-bit integers for smart contracts. Range: 0 to 255, encoded as single byte with no sign bit.

Example

final byte1 = U8Type.create(100);
final byte2 = U8Type.create(255); // Max value
final zero = U8Type.create(0);

print(byte1.nativeValue); // 100
print(byte2.toBytes()); // [255]
print(zero.toBytes()); // [0]

// Use in struct definitions
final structType = StructType(
  name: 'Counter',
  fieldDefinitions: [
    FieldDefinition(name: 'count', type: U8Type.type),
  ],
);
Inheritance
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) U8Value
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 other type.
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 of T, 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

Static Properties

type U8Type
Gets the singleton type instance for use in type definitions.
no setter

Static Methods

create(dynamic nativeValue) U8Value
Creates a U8Value from native Dart int.