ManagedDecimalValue class final
ManagedDecimal value representing a fixed-point decimal.
Holds a fixed-point decimal number as a raw BigInt value with scale metadata. Provides conversions to/from double and decimal strings.
Example
// From double
final price = ManagedDecimalValue.fromDouble(19.99, scale: 2);
print(price.toDecimalString()); // 19.99
print(price.nativeValue); // BigInt(1999) - raw value
// From string
final amount = ManagedDecimalValue.fromString('123.456', scale: 3);
print(amount.toDecimalString()); // 123.456
// From raw BigInt
final raw = ManagedDecimalValue(BigInt.from(1999), scale: 2);
print(raw.toDecimalString()); // 19.99
- Inheritance
-
- Object
- TypedValue
- ManagedDecimalValue
- Implementers
- Available extensions
- Annotations
-
- @immutable
Constructors
- ManagedDecimalValue(BigInt value, {required int scale, bool isSigned = false, bool isVariable = false})
- Creates a ManagedDecimal value.
- ManagedDecimalValue.fromDouble(double value, {required int scale, bool isSigned = false, bool isVariable = false})
-
Creates a ManagedDecimal from a double value.
factory
- ManagedDecimalValue.fromString(String value, {required int scale, bool isSigned = false, bool isVariable = false})
-
Creates a ManagedDecimal from a string representation.
factory
Properties
-
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
- hashCode → int
-
The hash code for this object.
no setterinherited
- isSigned → bool
-
Whether this is a signed decimal.
final
- isVariable → bool
-
Whether the scale is variable (encoded as U32 in data).
final
- nativeValue → BigInt
-
Returns native Dart representation of this value.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scale → int
-
Scale (number of decimal places).
final
- type → AbiType
-
Value type.
finalinherited
- value → BigInt
-
Underlying integer value (raw value without decimal point).
final
Methods
-
asOrNull<
T extends TypedValue> () → T? -
Available on TypedValue, provided by the TypedValueExtensions extension
Attempts to cast this value to typeT, returning null if the cast fails. -
asOrThrow<
T extends TypedValue> () → T -
Available on TypedValue, provided by the TypedValueExtensions extension
Casts this value to typeTwith a clear error message if the cast fails. -
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
requireValueType<
T extends TypedValue> (String message) → T -
Available on TypedValue, provided by the TypedValueValidationExtensions extension
Ensures this value is an instance ofT, throwing with a custom message if not. -
toBytes(
) → List< int> -
Converts to byte representation.
override
-
toDecimalString(
) → String - Converts to a string with proper decimal formatting.
-
toHex(
) → String -
Converts to hex string using nested encoding (fixed-width).
inherited
-
toString(
) → String -
A string representation of this object.
override
-
toTopBytes(
) → List< int> -
Converts to bytes using top-level encoding (variable-width).
inherited
-
toTopHex(
) → String -
Converts to hex string using top-level encoding (variable-width).
inherited
-
valueEquals(
TypedValue other) → bool -
Checks value equality.
inherited
-
valueOf(
) → dynamic -
Returns native value (alias for nativeValue).
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited