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.
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
anddenominatorUnits
.factory
Properties
- asInt → int?
-
If this is an integer according to isInt, returns value as an int.
read-only
-
asList
→ List<
Value> -
This value as a list.
read-onlyinherited
-
denominatorUnits
→ List<
String> -
This number's denominator units.
read-only
- hasBrackets → bool
-
Whether this value as a list has brackets.
read-onlyinherited
- hashCode → int
-
The hash code for this object.
read-onlyoverride
- hasUnits → bool
-
Whether this has any units.
read-only
- isInt → bool
-
Whether this is an integer, according to
fuzzyEquals
.read-only - isTruthy → bool
-
Whether the value counts as
true
in an@if
statement and other contexts.read-onlyinherited -
numeratorUnits
→ List<
String> -
This number's numerator units.
read-only
- realNull → Value?
-
Returns Dart's
null
value if this is sassNull, and returns this otherwise.read-onlyinherited - runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
- separator → ListSeparator
-
The separator for this value as a list.
read-onlyinherited
- unitString → String
-
Returns a human readable string representation of this number's units.
read-only
- value → double
-
The value of this number.
read-only
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 -
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 hasunit
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
andnewDenominators
. -
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
andnewDenominators
. -
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
andnewDenominators
. -
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
andnewDenominators
. -
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 givenunit
. -
valueInRange(
num min, num max, [String? name]) → double -
If value is between
min
andmax
, 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