Skip to content

FlutterComputed

Since Signals 0.6.0, you can use the signals_flutter import to create signals that extend ValueListenable.

import 'package:signals/signals_flutter.dart';
final count = computed(() => 0);
assert(count is Signal<int>);
assert(count is FlutterComputed<int>);
assert(count is FlutterReadonlySignal<int>);
assert(count is ValueListenable<int>);

Custom Signal

To create a custom signal that extends ValueListenable, use the ValueListenableSignalMixin mixin.

import 'package:signals/signals_flutter.dart';
class MySignal extends Computed<int> with ValueListenableSignalMixin<int> {
MySignal(int Function() cb) : super(cb);
}

Or extend FlutterComputed directly.

import 'package:signals/signals_flutter.dart';
class MySignal extends FlutterComputed<int> {
MySignal(int Function() cb) : super(cb);
}