Variable class final
A variable: a name, a type and a default value, or a formula that computes it from other variables. JSON (sparse):
{"id": "var1", "name": "count", "type": "integer", "value": 3}
{"id": "var2", "name": "total", "type": "decimal", "formula": "price * qty"}
{"id": "v3", "name": "clamp01", "formula": "min(1, max(0, v))", "parameters": ["v"]}
{"id": "v4", "name": "draft", "value": "", "persist": true}
- Annotations
-
- @immutable
Constructors
Properties
- extra → Json
-
Keys this version doesn't model, round-tripped.
final
- formula → String
-
The expression (what goes in
${= ...}) that computes the value of a computed variable; empty for a plain one. A computed variable is read-only: it changes when what its formula reads changes.final - hashCode → int
-
The hash code for this object.
no setteroverride
- id → String
-
final
- isComputed → bool
-
no setter
- isFunction → bool
-
no setter
- name → String
-
Unique in its scope; what expressions read (
${name}).final -
options
→ List<
VariableOption> -
The options of a VariableType.choice variable.
final
-
parameters
→ List<
String> -
A computed variable with parameters is a function: formulas call it by
name (
clamp01(x)), and its formula reads the arguments by these names.final - persist → bool
-
Whether the app keeps the value on the device: it starts from the
value it had last time (not value) and every change is saved. A
draft, a list the user builds up. A computed variable can't persist
(persists).
final
- persists → bool
-
Whether its value is kept on the device: persist, and not computed.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- type → VariableType
-
final
- value → Object?
-
The default value, as type holds it (see VariableType.coerce);
null when unset.
final
Methods
-
copyWith(
{String? id, String? name, VariableType? type, Object? value()?, String? formula, List< String> ? parameters, List<VariableOption> ? options, bool? persist, Json? extra}) → Variable -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Json -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override