SassNumber class abstract

A SassScript number.

Numbers can have units. Although there's no literal syntax for it, numbers support scientific-style numerator and denominator units (for example, miles/hour). These are expected to be resolved before being emitted to CSS.

Inheritance
Available extensions
Annotations
  • @sealed

Constructors

SassNumber(num value, [String? unit])
Creates a number, optionally with a single numerator unit.
factory
SassNumber.withUnits(num value, {List<String>? numeratorUnits, List<String>? denominatorUnits})
Creates a number with full numeratorUnits and denominatorUnits.
factory

Properties

asInt int?
If this is an integer according to isInt, returns value as an int.
no setter
asList List<Value>
This value as a list.
no setterinherited
denominatorUnits List<String>
This number's denominator units.
no setter
hasBrackets bool
Whether this value as a list has brackets.
no setterinherited
hasComplexUnits bool
Whether this has more than one numerator unit, or any denominator units.
no setter
hashCode int
The hash code for this object.
no setteroverride
hasUnits bool
Whether this has any units.
no setter
isInt bool
Whether this is an integer, according to fuzzyEquals.
no setter
isTruthy bool
Whether the value counts as true in an @if statement and other contexts.
no setterinherited
numeratorUnits List<String>
This number's numerator units.
no setter
realNull Value?
Returns Dart's null value if this is sassNull, and returns this otherwise.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
separator ListSeparator
The separator for this value as a list.
no setterinherited
unitString String
Returns a human readable string representation of this number's units.
no setter
value double
The value of this number.
no setter

Methods

accept<T>(ValueVisitor<T> visitor) → T
Calls the appropriate visit method on visitor.
assertBoolean([String? name]) SassBoolean
Throws a SassScriptException if this isn't a boolean.
inherited
assertCalculation([String? name]) SassCalculation
Throws a SassScriptException if this isn't a calculation.
inherited
assertColor([String? name]) SassColor
Throws a SassScriptException if this isn't a color.
inherited
assertFunction([String? name]) SassFunction
Throws a SassScriptException if this isn't a function reference.
inherited
assertInt([String? name]) int
Returns value as an int, if it's an integer value according to isInt.
assertMap([String? name]) SassMap
Throws a SassScriptException if this isn't a map.
inherited
assertMixin([String? name]) SassMixin
Throws a SassScriptException if this isn't a mixin reference.
inherited
assertNoUnits([String? name]) → void
Throws a SassScriptException unless this has no units.
assertNumber([String? name]) SassNumber
Throws a SassScriptException if this isn't a number.
override
assertString([String? name]) SassString
Throws a SassScriptException if this isn't a string.
inherited
assertUnit(String unit, [String? name]) → void
Throws a SassScriptException unless this has unit as its only unit (and as a numerator).
coerce(List<String> newNumerators, List<String> newDenominators, [String? name]) SassNumber
Returns a copy of this number, converted to the units represented by newNumerators and newDenominators.
coerceToMatch(SassNumber other, [String? name, String? otherName]) SassNumber
Returns a copy of this number, converted to the same units as other.
coerceValue(List<String> newNumerators, List<String> newDenominators, [String? name]) double
Returns value, converted to the units represented by newNumerators and newDenominators.
coerceValueToMatch(SassNumber other, [String? name, String? otherName]) double
Returns value, converted to the same units as other.
coerceValueToUnit(String unit, [String? name]) double
A shorthand for coerceValue with only one numerator unit.
compatibleWithUnit(String unit) bool
Returns whether this can be coerced to the given unit.
convert(List<String> newNumerators, List<String> newDenominators, [String? name]) SassNumber
Returns a copy of this number, converted to the units represented by newNumerators and newDenominators.
convertToMatch(SassNumber other, [String? name, String? otherName]) SassNumber
Returns a copy of this number, converted to the same units as other.
convertValue(List<String> newNumerators, List<String> newDenominators, [String? name]) double
Returns value, converted to the units represented by newNumerators and newDenominators.
convertValueToMatch(SassNumber other, [String? name, String? otherName]) double
Returns value, converted to the same units as other.
hasCompatibleUnits(SassNumber other) bool
Returns whether this has units that are compatible with other.
hasPossiblyCompatibleUnits(SassNumber other) bool
Returns whether this has units that are possibly-compatible with other, as defined by the Sass spec.
hasUnit(String unit) bool
Returns whether this has unit as its only unit (and as a numerator).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sassIndexToListIndex(Value sassIndex, [String? name]) int
Converts sassIndex into a Dart-style index into the list returned by asList.
inherited
toCssString({bool quote = true}) String
Returns a valid CSS representation of this.
inherited
toString() String
Returns a string representation of this.
inherited
tryMap() SassMap?
Returns this as a SassMap if it is one (including empty lists, which count as empty maps) or returns null if it's not.
inherited
unitSuggestion(String name, [String? unit]) String
Returns a suggested Sass snippet for converting a variable named name (without %) containing this number into a number with the same value and the given unit.
valueInRange(num min, num max, [String? name]) double
If value is between min and max, returns it.
valueInUnits(List<String> newNumerators, List<String> newDenominators, [String? name]) double
This has been renamed coerceValue for consistency with coerceToMatch, coerceValueToMatch, convertToMatch, and convertValueToMatch.
withListContents(Iterable<Value> contents, {ListSeparator? separator, bool? brackets}) SassList
Returns a new list containing contents that defaults to this value's separator and brackets.
inherited

Operators

operator ==(Object other) bool
The equality operator.
override

Constants

precision → const int
The number of distinct digits that are emitted when converting a number to CSS.