SassNumber class
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
- Object
- Value
- SassNumber
- Annotations
- @sealed
Constructors
- SassNumber(num value, [ String unit ])
-
Creates a number, optionally with a single numerator unit. [...]
factory
-
SassNumber.withUnits(num value, { Iterable<
String> numeratorUnits Iterable<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 -
denominatorUnits
→ List<
String> -
This number's denominator units.
read-only
- hasUnits → bool
-
Whether this has any units. [...]
read-only
- isInt → bool
-
Whether this is an integer, according to
fuzzyEquals
. [...]read-only -
numeratorUnits
→ List<
String> -
This number's numerator units.
read-only
- value → num
-
The value of this number. [...]
read-only
-
asList
→ List<
Value> -
This value as a list. [...]
read-only, inherited
- hasBrackets → bool
-
Whether this value as a list has brackets. [...]
read-only, inherited
- hashCode → int
-
The hash code for this object.
read-only, inherited
- isTruthy → bool
-
Whether the value counts as
true
in an@if
statement and other contexts.read-only, inherited - realNull → Value
-
Returns Dart's
null
value if this is sassNull, and returns this otherwise.read-only, inherited - runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- separator → ListSeparator
-
The separator for this value as a list. [...]
read-only, inherited
Methods
-
assertInt(
[String name ]) → int -
Returns value as an
int
, if it's an integer value according to isInt. [...] -
assertNoUnits(
[String name ]) → void -
Throws a
SassScriptException
unless this has no units. [...] -
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) → SassNumber -
Returns a copy of this number, converted to the units represented by
newNumerators
andnewDenominators
. [...] -
hasUnit(
String unit) → bool -
Returns whether this has
unit
as its only unit (and as a numerator). -
valueInRange(
num min, [ num max, [ String name ]) → num -
If value is between
min
andmax
, returns it. [...] -
valueInUnits(
List< String> newNumerators List<String> newDenominators) → num -
Returns value, converted to the units represented by
newNumerators
andnewDenominators
. [...] -
assertBoolean(
[String name ]) → SassBoolean -
Throws a
SassScriptException
if this isn't a boolean. [...]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 -
assertMap(
[String name ]) → SassMap -
Throws a
SassScriptException
if this isn't a map. [...]inherited -
assertNumber(
[String name ]) → SassNumber -
Throws a
SassScriptException
if this isn't a number. [...]inherited -
assertString(
[String name ]) → SassString -
Throws a
SassScriptException
if this isn't a string. [...]inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent 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(
) → String -
Returns a valid CSS representation of this. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator.
inherited
Constants
- precision → const int
-
The number of distinct digits that are emitted when converting a number to
CSS.
10