Reactive<T extends Reactive<T>> class abstract mixin

Reactive mixin class that provides a signal-based reactive system.

The Reactive allows you to implement your own reactive types.

Example:

class Counter with Reactive<Counter> {
  int untrackedValue = 0;

  int get value {
    track();
    return untrackedValue;
  }

  void increment() {
    untrackedValue++;
    trigger();
  }
}

class CounterWidget extends StatelessWidget {
  const CounterWidget({Key? key});

  @override
  Widget build(BuildContext context) {
    final counter = useMemoized(context, Counter.new);

    return Column(
      children: [
        Text('${counter.value}'),
        TextButton(
          onPressed: counter.increment,
          child: const Text('Increment'),
        ),
      ],
    );
  }
}

Reference:

Implementers

Constructors

Reactive()

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
track() → void
Tracks the current reactive state.
trigger() → void
Triggers a change in the reactive state.

Operators

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