Node class final

One node: a widget declaration's values, placed in a tree by id.

Immutable, with value equality over every field, so "did this node change?" is ==. It holds no parent pointer (the document derives the parent index) and no computed geometry.

Available extensions
Annotations
  • @immutable

Constructors

Node({required String id, required String type, String name = '', String key = '', List<String> children = const [], Map<String, String> slots = const {}, bool visible = true, double opacity = 1, Layout layout = const Layout(), Decoration decoration = Decoration.none, Props props = Props.empty, Map<String, String> bind = const {}, List<Reaction> actions = const [], Behaviors behaviors = Behaviors.none, ComponentLink? component, List<MediaRule> media = const [], Json extra = const {}, Catalog? catalog})
const

Properties

actions → List<Reaction>
Reactions: trigger → the chain of actions it runs.
final
behaviors → Behaviors
Motion, loops, transitions, ink, interaction states, drag and drop... (stored flat in the node's JSON, under Behaviors.keys).
final
bind → Map<String, String>
Bound properties: a binding path (visible, props.text, layout.width, decoration.fills.<paintId>; see BindPaths and DESIGN.md §5.1) → an expression (${user.name}, ${= qty * 2}).
final
catalog → Catalog?
The catalog this node was decoded with; null for a node built in code (its spec is then Catalog.current's). Not part of its value: two nodes with the same fields are equal whatever catalog read them.
final
childIds → Iterable<String>
Every child id: slots, then the ordered children, then (for a variance) each variant's children.
no setter
children → List<String>
Ordered children.
final
component → ComponentLink?
The component this node is the main node of, or the top node of an instance of (DESIGN.md §4.2).
final
currentVarianceVariant → Json?

Available on Node, provided by the VarianceBreakpoints extension

The variant shown: VarianceProps.current's, else the first.
no setter
decoration → Decoration
final
extra → Json
Keys this version doesn't model, round-tripped.
final
hashCode → int
The hash code for this object.
no setteroverride
id → String
final
isResponsive → bool

Available on Node, provided by the VarianceBreakpoints extension

Whether it maps variants to breakpoints (and shows the one for the screen's width).
no setter
key → String
The node's name within the tree it was inserted with, unique in that tree ("content"): a stable handle the tree's own actions and states name it by before it has an id, kept so an export gives the tree back with its keys. Empty for none; it doesn't affect rendering.
final
layout → Layout
final
media → List<MediaRule>
Its own fields by screen size, as CSS media queries: rules whose conditions (minWidth, maxWidth: px or a breakpoint name; orientation) hold patch the node, in order.
final
name → String
final
opacity → double
final
props → Props
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
slots → Map<String, String>
Named children, by slot.
final
spec → WidgetSpec?
The declaration, or null for a type the node's catalog doesn't declare.
no setter
type → String
The widget type: a key of Widgets.
final
varianceVariants → List<Json>

Available on Node, provided by the VarianceBreakpoints extension

Its variants ({"id", "name", "children", "breakpoint"?}).
no setter
visible → bool
final

Methods

atScreen(double width, double? height, Breakpoints breakpoints) → Node
This node as shown on a screen width × height: its media rules that hold, merged over it in order. Itself when none holds.
breakpointForWidth(double width, Breakpoints breakpoints) → Breakpoint

Available on Node, provided by the VarianceBreakpoints extension

The breakpoint this responsive variance shows at width of breakpoints, by its own switch points (VarianceProps.minWidths).
copyWith({String? id, String? type, String? name, String? key, List<String>? children, Map<String, String>? slots, bool? visible, double? opacity, Layout? layout, Decoration? decoration, Props? props, Map<String, String>? bind, List<Reaction>? actions, Behaviors? behaviors, ComponentLink? component, List<MediaRule>? media, Json? extra}) → Node
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
patched(Json patch) → Node
This node with patch (a JSON merge patch over its JSON, as an interaction state's) applied, as its declarations read it: a value of a union type (a size, a position, a paint...) written in another form is replaced, not merged (mergeNodePatch).
prop<T>(PropDef<T> def) → T
toJson() → Json
toString() → String
A string representation of this object.
override
variantForWidth(double width, Breakpoints breakpoints) → Json?

Available on Node, provided by the VarianceBreakpoints extension

The variant this variance shows on a screen width wide: a responsive one, the variant of the breakpoint the width resolves to by its own switch points (breakpointForWidth), else of the widest narrower breakpoint that has one, else the narrowest (variantIdForBreakpoint); any other, its current one.
variantIdForBreakpoint(String breakpointId, Breakpoints breakpoints) → String?

Available on Node, provided by the VarianceBreakpoints extension

The id of the variant for breakpoint breakpointId: a variant shows from its breakpoint up to the next variant's (min-width semantics, as a screen's canvases), so its own, else the widest narrower one's (Breakpoints.governing); below every variant, the narrowest. Null when no variant names a breakpoint of breakpoints.
withComponent(ComponentLink? link) → Node
This node linked to a component, or unlinked (null).
withProp<T>(PropDef<T> def, T value) → Node

Operators

operator ==(Object other) → bool
The equality operator.
override

Static Methods

fromJson(Object? json, {String? id, Catalog? catalog}) → Node?
Decodes a node with catalog (default: Catalog.current); id wins over the JSON's own (the document map key). Returns null only when there's no type. A type the catalog doesn't declare keeps its props raw (Props.unknown).