Skip to content

SignalsMixin

SignalsMixin is a mixin for State that auto disposes signals when the widget is removed from the widget tree.

Signals

Signal, computed, value signals, and async signals can be created with helper methods prefixed with create*.

class _MyState extends State<MyWidget> with SignalsMixin {
late final count = createSignal(0);
late final isEven = createComputed(() => signal.value.isEven);
late final list = createListSignal(0);
}

Effects

Effects can be created with the createEffect method. They will get disposed when the widget is removed from the widget tree.

class _MyState extends State<MyWidget> with SignalsMixin {
@override
void initState() {
super.initState();
createEffect(() => print('Effect created'));
}
}