ViewComponent class abstract

A lightweight, composable TUI component.

Unlike a full Model, a ViewComponent is designed to be hosted inside a parent model. It follows the same Elm Architecture pattern (init/update/view) but is optimized for composition.

Example

class MyComponent extends ViewComponent {
  int count = 0;

  @override
  (ViewComponent, Cmd?) update(Msg msg) {
    if (msg is IncrementMsg) {
      count++;
      return (this, null);
    }
    return (this, null);
  }

  @override
  String view() => 'Count: $count';
}
Inheritance
Implementers

Constructors

ViewComponent()
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

init() Cmd?
Returns an optional command to execute on program startup.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
update(Msg msg) → (ViewComponent, Cmd?)
Updates the component state in response to a message.
override
view() Object
Renders the current model state for display.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited