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
numeratorUnitsanddenominatorUnits.factory
Properties
- asInt → int?
-
If
thisis 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
thishas more than one numerator unit, or any denominator units.no setter - hashCode → int
-
The hash code for this object.
no setteroverride
- hasUnits → bool
-
Whether
thishas any units.no setter - isInt → bool
-
Whether
thisis an integer, according tofuzzyEquals.no setter - isTruthy → bool
-
Whether the value counts as
truein an@ifstatement and other contexts.no setterinherited -
numeratorUnits
→ List<
String> -
This number's numerator units.
no setter
- realNull → Value?
-
Returns Dart's
nullvalue if this is sassNull, and returnsthisotherwise.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
SassScriptExceptionifthisisn't a boolean.inherited -
assertCalculation(
[String? name]) → SassCalculation -
Throws a
SassScriptExceptionifthisisn't a calculation.inherited -
assertColor(
[String? name]) → SassColor -
Throws a
SassScriptExceptionifthisisn't a color.inherited -
assertComplexSelector(
{String? name, bool allowParent = false}) → ComplexSelector -
Available on Value, provided by the SassApiValue extension
Parsesthisas a complex selector, in the same manner as theselector-parse()function. -
assertCompoundSelector(
{String? name, bool allowParent = false}) → CompoundSelector -
Available on Value, provided by the SassApiValue extension
Parsesthisas a compound selector, in the same manner as theselector-parse()function. -
assertFunction(
[String? name]) → SassFunction -
Throws a
SassScriptExceptionifthisisn'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
SassScriptExceptionifthisisn't a map.inherited -
assertMixin(
[String? name]) → SassMixin -
Throws a
SassScriptExceptionifthisisn't a mixin reference.inherited -
assertNoUnits(
[String? name]) → void -
Throws a
SassScriptExceptionunlessthishas no units. -
assertNumber(
[String? name]) → SassNumber -
Throws a
SassScriptExceptionifthisisn't a number.override -
assertSelector(
{String? name, bool allowParent = false}) → SelectorList -
Available on Value, provided by the SassApiValue extension
Parsesthisas a selector list, in the same manner as theselector-parse()function. -
assertSimpleSelector(
{String? name, bool allowParent = false}) → SimpleSelector -
Available on Value, provided by the SassApiValue extension
Parsesthisas a simple selector, in the same manner as theselector-parse()function. -
assertString(
[String? name]) → SassString -
Throws a
SassScriptExceptionifthisisn't a string.inherited -
assertUnit(
String unit, [String? name]) → void -
Throws a
SassScriptExceptionunlessthishasunitas 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
newNumeratorsandnewDenominators. -
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
newNumeratorsandnewDenominators. -
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
thiscan be coerced to the givenunit. -
convert(
List< String> newNumerators, List<String> newDenominators, [String? name]) → SassNumber -
Returns a copy of this number, converted to the units represented by
newNumeratorsandnewDenominators. -
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
newNumeratorsandnewDenominators. -
convertValueToMatch(
SassNumber other, [String? name, String? otherName]) → double -
Returns value, converted to the same units as
other. -
convertValueToUnit(
String unit, [String? name]) → double - A shorthand for convertValue with only one numerator unit.
-
hasCompatibleUnits(
SassNumber other) → bool -
Returns whether
thishas units that are compatible withother. -
hasUnit(
String unit) → bool -
Returns whether
thishasunitas 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
sassIndexinto 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
thisas a SassMap if it is one (including empty lists, which count as empty maps) or returnsnullif it's not.inherited -
valueInRange(
num min, num max, [String? name]) → double -
If value is between
minandmax, 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
contentsthat defaults to this value's separator and brackets.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override