evaluate method
- StyleExpressionInputs? inputs,
Evaluates a style expression and writes its result as JSON.
A number in the result that isn't finite becomes null. A color is
["rgba", r, g, b, a], with red, green, and blue from 0 to 255 and alpha
from 0 to 1, each exact only to single precision. Formatted text is a
["format", …] expression, an image is {"name": …, "available": …},
padding is [top, right, bottom, left], and a variable anchor offset is
[anchor, [x, y], …].
See mln_style_expression_evaluate in the
C API reference.
Errors:
Status.invalidArgumentwhen the expression fails to evaluate, such as when it reads an input thatinputsdoesn't set.
Implementation
Object? evaluate({StyleExpressionInputs? inputs}) => withNativeArena((arena) {
final text = _CallerSizedText();
final nativeInputs = inputs == null
? nullptr
: _writeStyleExpressionInputs(inputs, arena);
_check(
text.call(
arena,
(textStorage, textCapacity, textLength) =>
raw.mln_style_expression_evaluate(
_handle.raw,
nativeInputs,
textStorage,
textCapacity,
textLength,
nativeDiagnostic,
),
),
);
return _decodeJson(text.text);
});