Expression<T> class
sealed
A value of a style property or an argument of another expression: either a constant (Expression.literal) or a style expression that the map evaluates.
T is the Dart type the expression evaluates to, such as num, String,
bool, Color, Offset, a List or a spec enum like LineCap.
CircleStyleLayer(
id: 'quakes',
sourceId: 'quakes',
filter: .all([
.greaterThan(.get('mag').asNumber(), .literal(5)),
.has('place'),
]),
radius: .interpolate(.exponential(2), .zoom(), {
5: .literal(2),
10: .literal(8),
}),
);
Dot shorthands don't work as operands of an operator. Start with
Expression. there: Expression.get('mag').asNumber() > .literal(5).
Spec names are kept, except for those that clash with Dart keywords or
members: case is select, in is contains, let and var are
withVariable, ! is not(), == and != are equal and notEqual,
typeof is type, string, number and boolean are asString,
asNumber and asBoolean, and to-string and the like are
convertToString and the like.
- Available extensions
- Annotations
Constructors
- Expression.literal(T value)
-
The constant
value.constfactory -
Expression.raw(List<
Object?> json) -
The expression
jsonin the JSON form of the style spec. The fallback for anything not covered by this class.constfactory
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
abs(
) → Expression< num> -
Available on Expression<
The absolute value (spec:num> , provided by the NumExpression extensionabs). -
acos(
) → Expression< num> -
Available on Expression<
The arccosine (spec:num> , provided by the NumExpression extensionacos). -
asArray<
E> ({int? length}) → Expression< List< E> > -
Asserts that this value is an array of
E, optionally oflengthitems (spec:array). Only num, String and bool can be asserted as item types; any otherEasserts an array of any items, which can't be combined with alength. -
asBoolean(
[List< Expression< fallbacks = const []]) → Expression<Object?> >bool> -
Asserts that this value is a boolean. If it isn't, the
fallbacksare tried in order (spec:boolean). -
asin(
) → Expression< num> -
Available on Expression<
The arcsine (spec:num> , provided by the NumExpression extensionasin). -
asNumber(
[List< Expression< fallbacks = const []]) → Expression<Object?> >num> -
Asserts that this value is a number. If it isn't, the
fallbacksare tried in order (spec:number). -
asObject(
[List< Expression< fallbacks = const []]) → Expression<Object?> >Map< String, Object?> > -
Asserts that this value is an object. If it isn't, the
fallbacksare tried in order (spec:object). -
asString(
[List< Expression< fallbacks = const []]) → Expression<Object?> >String> -
Asserts that this value is a string. If it isn't, the
fallbacksare tried in order (spec:string). -
at(
Expression< num> index) → Expression<E> -
Available on Expression<
The item atList< , provided by the ListExpression extensionE> >index(spec:at). -
atan(
) → Expression< num> -
Available on Expression<
The arctangent (spec:num> , provided by the NumExpression extensionatan). -
cast<
R> () → Expression< R> -
Asserts nothing and only changes the static type to
R. Use asString, asNumber or asBoolean for an assertion that the map checks. A Literal whose value is not anRbecomes a RawValue of its JSON. -
ceil(
) → Expression< num> -
Available on Expression<
The smallest integer not below this (spec:num> , provided by the NumExpression extensionceil). -
contains(
Expression< String> substring) → Expression<bool> -
Available on Expression<
Whether this containsString> , provided by the StringExpression extensionsubstring(spec:in). -
contains(
Expression< E> item) → Expression<bool> -
Available on Expression<
Whether this containsList< , provided by the ListExpression extensionE> >item(spec:in). -
convertToBoolean(
) → Expression< bool> -
Converts this value to a boolean (spec:
to-boolean). -
convertToColor(
[List< Expression< fallbacks = const []]) → Expression<Object?> >Color> -
Converts this value to a color. If that fails, the
fallbacksare tried in order (spec:to-color). -
convertToNumber(
[List< Expression< fallbacks = const []]) → Expression<Object?> >num> -
Converts this value to a number. If that fails, the
fallbacksare tried in order (spec:to-number). -
convertToString(
) → Expression< String> -
Converts this value to a string (spec:
to-string). -
cos(
) → Expression< num> -
Available on Expression<
The cosine (spec:num> , provided by the NumExpression extensioncos). -
downcase(
) → Expression< String> -
Available on Expression<
This in lowercase (spec:String> , provided by the StringExpression extensiondowncase). -
floor(
) → Expression< num> -
Available on Expression<
The largest integer not above this (spec:num> , provided by the NumExpression extensionfloor). -
indexOf(
Expression< E> item, {Expression<num> ? from}) → Expression<num> -
Available on Expression<
The position of the firstList< , provided by the ListExpression extensionE> >itemat or afterfrom, or -1 (spec:index-of). -
indexOf(
Expression< String> substring, {Expression<num> ? from}) → Expression<num> -
Available on Expression<
The position of the firstString> , provided by the StringExpression extensionsubstringat or afterfrom, or -1 (spec:index-of). -
isSupportedScript(
) → Expression< bool> -
Available on Expression<
Whether the map can render this string's script (spec:String> , provided by the StringExpression extensionis-supported-script). -
join(
Expression< String> separator) → Expression<String> -
Available on Expression<
The items joined byList< , provided by the ListExpression extensionE> >separator(spec:join). -
length(
) → Expression< num> -
Available on Expression<
The length in UTF-16 code units (spec:String> , provided by the StringExpression extensionlength). -
length(
) → Expression< num> -
Available on Expression<
The number of items (spec:List< , provided by the ListExpression extensionE> >length). -
ln(
) → Expression< num> -
Available on Expression<
The natural logarithm (spec:num> , provided by the NumExpression extensionln). -
log10(
) → Expression< num> -
Available on Expression<
The base-ten logarithm (spec:num> , provided by the NumExpression extensionlog10). -
log2(
) → Expression< num> -
Available on Expression<
The base-two logarithm (spec:num> , provided by the NumExpression extensionlog2). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
not(
) → Expression< bool> -
Available on Expression<
The opposite of this (spec:bool> , provided by the BoolExpression extension!). -
numberFormat(
{Expression< String> ? locale, Expression<String> ? currency, Expression<num> ? minFractionDigits, Expression<num> ? maxFractionDigits}) → Expression<String> -
Available on Expression<
This number as a string in a locale-dependent format (spec:num> , provided by the NumExpression extensionnumber-format). -
pow(
Expression< num> exponent) → Expression<num> -
Available on Expression<
This to the power ofnum> , provided by the NumExpression extensionexponent(spec:^). -
resolvedLocale(
) → Expression< String> -
Available on Expression<
The IETF language tag of the locale of this collator (spec:Collator> , provided by the CollatorExpression extensionresolved-locale). -
round(
) → Expression< num> -
Available on Expression<
Rounded to the nearest integer, halves away from zero (spec:num> , provided by the NumExpression extensionround). -
sin(
) → Expression< num> -
Available on Expression<
The sine (spec:num> , provided by the NumExpression extensionsin). -
slice(
Expression< num> start, [Expression<num> ? end]) → Expression<List< E> > -
Available on Expression<
The items fromList< , provided by the ListExpression extensionE> >start, up toendif given (spec:slice). -
slice(
Expression< num> start, [Expression<num> ? end]) → Expression<String> -
Available on Expression<
The part of this fromString> , provided by the StringExpression extensionstart, up toendif given (spec:slice). -
split(
Expression< String> separator) → Expression<List< String> > -
Available on Expression<
The substrings between the occurrences ofString> , provided by the StringExpression extensionseparator(spec:split). -
sqrt(
) → Expression< num> -
Available on Expression<
The square root (spec:num> , provided by the NumExpression extensionsqrt). -
tan(
) → Expression< num> -
Available on Expression<
The tangent (spec:num> , provided by the NumExpression extensiontan). -
toJson(
) → Object? - The expression in the JSON form of the style spec.
-
toRgba(
) → Expression< List< num> > -
Available on Expression<
The red, green, blue and alpha components of this color (spec:Color> , provided by the ColorExpression extensionto-rgba). -
toString(
) → String -
A string representation of this object.
override
-
type(
) → Expression< String> -
The type of this value as a string (spec:
typeof). -
upcase(
) → Expression< String> -
Available on Expression<
This in uppercase (spec:String> , provided by the StringExpression extensionupcase).
Operators
-
operator %(
Expression< num> other) → Expression<num> -
Available on Expression<
The remainder of this divided bynum> , provided by the NumExpression extensionother(spec:%). -
operator *(
Expression< num> other) → Expression<num> -
Available on Expression<
The product of this andnum> , provided by the NumExpression extensionother(spec:*). -
operator +(
Expression< num> other) → Expression<num> -
Available on Expression<
The sum of this andnum> , provided by the NumExpression extensionother(spec:+). -
operator +(
Expression< String> other) → Expression<String> -
Available on Expression<
This andString> , provided by the StringExpression extensionotherjoined (spec:concat). -
operator -(
Expression< num> other) → Expression<num> -
Available on Expression<
This minusnum> , provided by the NumExpression extensionother(spec:-). -
operator /(
Expression< num> other) → Expression<num> -
Available on Expression<
This divided bynum> , provided by the NumExpression extensionother(spec:/). -
operator <(
Expression< num> other) → Expression<bool> -
Available on Expression<
Whether this is less thannum> , provided by the NumExpression extensionother(spec:<). -
operator <(
Expression< String> other) → Expression<bool> -
Available on Expression<
Whether this sorts beforeString> , provided by the StringExpression extensionother(spec:<). -
operator <=(
Expression< num> other) → Expression<bool> -
Available on Expression<
Whether this is less than or equal tonum> , provided by the NumExpression extensionother(spec:<=). -
operator <=(
Expression< String> other) → Expression<bool> -
Available on Expression<
Whether this sorts before or equal toString> , provided by the StringExpression extensionother(spec:<=). -
operator ==(
Object other) → bool -
The equality operator.
override
-
operator >(
Expression< num> other) → Expression<bool> -
Available on Expression<
Whether this is greater thannum> , provided by the NumExpression extensionother(spec:>). -
operator >(
Expression< String> other) → Expression<bool> -
Available on Expression<
Whether this sorts afterString> , provided by the StringExpression extensionother(spec:>). -
operator >=(
Expression< num> other) → Expression<bool> -
Available on Expression<
Whether this is greater than or equal tonum> , provided by the NumExpression extensionother(spec:>=). -
operator >=(
Expression< String> other) → Expression<bool> -
Available on Expression<
Whether this sorts after or equal toString> , provided by the StringExpression extensionother(spec:>=). -
operator unary-(
) → Expression< num> -
Available on Expression<
This negated (spec:num> , provided by the NumExpression extension-).
Static Methods
-
accumulated(
) → Expression< Object?> -
The value of a cluster property accumulated so far (spec:
accumulated). -
all(
List< Expression< values) → Expression<bool> >bool> -
Whether all of
valuesare true (spec:all). -
any(
List< Expression< values) → Expression<bool> >bool> -
Whether any of
valuesis true (spec:any). -
coalesce<
R> (List< Expression< values) → Expression<R> >R> -
The first of
valuesthat isn't null (spec:coalesce). -
collator(
{Expression< bool> ? caseSensitive, Expression<bool> ? diacriticSensitive, Expression<String> ? locale}) → Expression<Collator> -
A collator for locale-dependent comparisons (spec:
collator). -
concat(
List< Expression< values) → Expression<Object?> >String> -
The
valuesjoined to one string (spec:concat).+joins two strings. -
distance(
Map< String, Object?> geometry) → Expression<num> -
The shortest distance in meters from the feature to the GeoJSON
geometry(spec:distance). -
e(
) → Expression< num> -
The mathematical constant e (spec:
e). -
elevation(
) → Expression< num> -
The elevation in meters at a point (spec:
elevation). -
equal(
Expression< Object?> a, Expression<Object?> b, {Expression<Collator> ? collator}) → Expression<bool> -
Whether
aequalsb(spec:==). -
featureState(
String name) → Expression< Object?> -
The property
nameof the feature's state (spec:feature-state). -
format(
List< FormatSection> sections) → Expression<String> -
A formatted string of mixed fonts and images, for a text field (spec:
format). -
geometryType(
) → Expression< String> -
The geometry type of the feature (spec:
geometry-type). -
get(
String name, {Expression< Map< ? object}) → Expression<String, Object?> >Object?> -
The property
nameof the feature, or ofobjectif given (spec:get). -
globalState(
String name) → Expression< Object?> -
The property
namefrom the global state (spec:global-state). -
greaterThan(
Expression< Object?> a, Expression<Object?> b, {Expression<Collator> ? collator}) → Expression<bool> -
Whether
ais greater thanb(spec:>). -
greaterThanOrEqual(
Expression< Object?> a, Expression<Object?> b, {Expression<Collator> ? collator}) → Expression<bool> -
Whether
ais greater than or equal tob(spec:>=). -
has(
String name, {Expression< Map< ? object}) → Expression<String, Object?> >bool> -
Whether the feature, or
objectif given, has the propertyname(spec:has). -
heatmapDensity(
) → Expression< num> -
The density at a point of a heatmap, for its color (spec:
heatmap-density). -
id(
) → Expression< Object?> -
The id of the feature (spec:
id). -
image(
Expression< String> name) → Expression<String> -
The image
nameof the style, for an icon, pattern or formatted text (spec:image). -
interpolate<
R> (Interpolation interpolation, Expression< num> input, Map<num, Expression< stops) → Expression<R> >R> -
Interpolates between the outputs of the
stopsatinput(spec:interpolate). The stops are sorted on serialization. -
interpolateHcl(
Interpolation interpolation, Expression< num> input, Map<num, Expression< stops) → Expression<Color> >Color> -
Like interpolate, for colors in the Hue-Chroma-Luminance color space
(spec:
interpolate-hcl). -
interpolateLab(
Interpolation interpolation, Expression< num> input, Map<num, Expression< stops) → Expression<Color> >Color> -
Like interpolate, for colors in the CIELAB color space (spec:
interpolate-lab). -
lessThan(
Expression< Object?> a, Expression<Object?> b, {Expression<Collator> ? collator}) → Expression<bool> -
Whether
ais less thanb(spec:<). -
lessThanOrEqual(
Expression< Object?> a, Expression<Object?> b, {Expression<Collator> ? collator}) → Expression<bool> -
Whether
ais less than or equal tob(spec:<=). -
lineProgress(
) → Expression< num> -
The progress along a line from 0 to 1, for its gradient. Needs a GeoJSON
source with line metrics (spec:
line-progress). -
ln2(
) → Expression< num> -
The mathematical constant ln(2) (spec:
ln2). -
match<
R> (Expression< Object?> input, Map<Object, Expression< cases, {required Expression<R> >R> fallback}) → Expression<R> -
The output whose label equals
input, or elsefallback. A label is a string, a number or a list of them (spec:match). -
max(
List< Expression< values) → Expression<num> >num> -
The largest of
values(spec:max). -
min(
List< Expression< values) → Expression<num> >num> -
The smallest of
values(spec:min). -
notEqual(
Expression< Object?> a, Expression<Object?> b, {Expression<Collator> ? collator}) → Expression<bool> -
Whether
adiffers fromb(spec:!=). -
pi(
) → Expression< num> -
The mathematical constant pi (spec:
pi). -
product(
List< Expression< values) → Expression<num> >num> -
The product of
values(spec:*).*multiplies two. -
properties(
) → Expression< Map< String, Object?> > -
The properties of the feature (spec:
properties). -
rgb(
Expression< num> red, Expression<num> green, Expression<num> blue) → Expression<Color> -
A color of the components
red,greenandbluefrom 0 to 255 (spec:rgb). -
rgba(
Expression< num> red, Expression<num> green, Expression<num> blue, Expression<num> alpha) → Expression<Color> -
A color of the components
red,greenandbluefrom 0 to 255 andalphafrom 0 to 1 (spec:rgba). -
select<
R> (List< (Expression< branches, {required Expression<bool> , Expression<R> )>R> fallback}) → Expression<R> -
The output of the first branch whose test is true, or else
fallback(spec:case). -
semiliteral<
E> (List< Expression< items) → Expression<E> >List< E> > -
An array of the
items, which unlike a Expression.literal may be expressions (spec:semiliteral). -
step<
R> (Expression< num> input, Expression<R> output0, Map<num, Expression< stops) → Expression<R> >R> -
The output of the last stop at or below
input, oroutput0below the first stop (spec:step). The stops are sorted on serialization. -
sum(
List< Expression< values) → Expression<num> >num> -
The sum of
values(spec:+).+adds two. -
within(
Map< String, Object?> geometry) → Expression<bool> -
Whether the feature lies inside the GeoJSON
geometry(spec:within). -
withVariable<
V, R> (String name, Expression< V> value, Expression<R> body(Variable<V> variable)) → Expression<R> -
Binds
valueto the variablenamefor the expression thatbodyreturns (spec:letandvar). -
zoom(
) → Expression< num> -
The zoom level of the map (spec:
zoom).