Computed<T> class
Data is often derived from other pieces of existing data. The computed function lets you combine the values of multiple signals into a new signal that can be reacted to, or even used by additional computeds. When the signals accessed from within a computed callback change, the computed callback is re-executed and its new return value becomes the computed signal's value.
Computedclass extends theSignalclass, so you can use it anywhere you would use a signal.
import 'package:signals/signals.dart';
final name = signal("Jane");
final surname = signal("Doe");
final fullName = computed(() => name.value + " " + surname.value);
// Logs: "Jane Doe"
print(fullName.value);
// Updates flow through computed, but only if someone
// subscribes to it. More on that later.
name.value = "John";
// Logs: "John Doe"
print(fullName.value);
Any signal that is accessed inside the computed's callback function will be automatically subscribed to and tracked as a dependency of the computed signal.
Computed signals are both lazily evaluated and memoized
Force Re-evaluation
You can force a computed signal to re-evaluate by calling its .recompute method. This will re-run the computed callback and update the computed signal's value.
final name = signal("Jane");
final surname = signal("Doe");
final fullName = computed(() => name.value + " " + surname.value);
fullName.recompute(); // Re-runs the computed callback
Disposing
Auto Dispose
If a computed signal is created with autoDispose set to true, it will automatically dispose itself when there are no more listeners.
final s = computed(() => 0, autoDispose: true);
s.onDispose(() => print('Signal destroyed'));
final dispose = s.subscribe((_) {});
dispose();
final value = s.value; // 0
// prints: Signal destroyed
A auto disposing signal does not require its dependencies to be auto disposing. When it is disposed it will freeze its value and stop tracking its dependencies.
This means that it will no longer react to changes in its dependencies.
final s = computed(() => 0);
s.dispose();
final value = s.value; // 0
final b = computed(() => s.value); // 0
// b will not react to changes in s
You can check if a signal is disposed by calling the .disposed method.
final s = computed(() => 0);
print(s.disposed); // false
s.dispose();
print(s.disposed); // true
On Dispose Callback
You can attach a callback to a signal that will be called when the signal is destroyed.
final s = computed(() => 0);
s.onDispose(() => print('Signal destroyed'));
s.dispose();
Flutter
In Flutter if you want to create a signal that automatically disposes itself when the widget is removed from the widget tree and rebuilds the widget when the signal changes, you can use the createComputed inside a stateful widget.
import 'package:flutter/material.dart';
import 'package:signals/signals_flutter.dart';
class CounterWidget extends StatefulWidget {
@override
_CounterWidgetState createState() => _CounterWidgetState();
}
class _CounterWidgetState extends State<CounterWidget> with SignalsMixin {
late final counter = createSignal(0);
late final isEven = createComputed(() => counter.value.isEven);
late final isOdd = createComputed(() => counter.value.isOdd);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Counter: even=$isEven, odd=$isOdd'),
ElevatedButton(
onPressed: () => counter.value++,
child: Text('Increment'),
),
],
),
),
);
}
}
No Watch widget or extension is needed, the signal will automatically dispose itself when the widget is removed from the widget tree.
The SignalsMixin is a mixin that automatically disposes all signals created in the state when the widget is removed from the widget tree.
Testing
Testing computed signals is possible by converting a computed to a stream and testing it like any other stream in Dart.
test('test as stream', () {
final a = signal(0);
final s = computed(() => a());
final stream = s.toStream();
a.value = 1;
a.value = 2;
a.value = 3;
expect(stream, emitsInOrder([0, 1, 2, 3]));
});
emitsInOrder is a matcher that will check if the stream emits the values in the correct order which in this case is each value after a signal is updated.
You can also override the initial value of a computed signal when testing. This is is useful for mocking and testing specific value implementations.
test('test with override', () {
final a = signal(0);
final s = computed(() => a()).overrideWith(-1);
final stream = s.toStream();
a.value = 1;
a.value = 2;
a.value = 2; // check if skipped
a.value = 3;
expect(stream, emitsInOrder([-1, 1, 2, 3]));
});
overrideWith returns a new computed signal with the same global id sets the value as if the computed callback returned it.
@link https://dartsignals.dev/core/computed
- Implemented types
- Mixed-in types
- Available extensions
- BoolSignalExtension
- ComparableSignalExtension
- DoubleSignalExtension
- EnumSignalExtension
- FlutterReadonlySignalUtils
- IntSignalExtension
- NumSignalExtension
- PatternSignalExtension
- ReadonlyIterableSignalExtension
- ReadonlyListSignalExtension
- ReadonlyMapSignalExtension
- ReadonlySetSignalExtension
- ReadonlySignalUtils
- SignalObserveExtension
- StringSignalExtension
Constructors
- Computed(T fn(), {String? debugLabel, bool autoDispose = false})
-
Data is often derived from other pieces of existing data. The
computedfunction lets you combine the values of multiple signals into a new signal that can be reacted to, or even used by additional computeds. When the signals accessed from within a computed callback change, the computed callback is re-executed and its new return value becomes the computed signal's value.
Properties
- autoDispose ↔ bool
-
Throws and error if read after dispose and can be
disposed on last unsubscribe.
getter/setter pairinherited
- bitLength → int
-
Available on ReadonlySignal<
Returns the minimum number of bits required to store this integer.int> , provided by the IntSignalExtension extensionno setter -
codeUnits
→ List<
int> -
Available on ReadonlySignal<
An unmodifiable list of the UTF-16 code units of this string.String> , provided by the StringSignalExtension extensionno setter - debugLabel → String?
-
Debug label for Debug Mode
final
- disposed ↔ bool
-
Check if the effect is disposed
getter/setter pairinherited
-
entries
→ Iterable<
MapEntry< K, V> > -
Available on ReadonlySignal<
Map< , provided by the ReadonlyMapSignalExtension extensionK, V> >no setter - first → E
-
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> >no setter - flags ↔ int
-
getter/setter pairinherited
- globalId → int
-
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
Available on ReadonlySignal<
A numeric identifier for the enumerated value.Enum> , provided by the EnumSignalExtension extensionno setter - internalValue ↔ T
-
getter/setter pairinherited-getter
- isEmpty → bool
-
Available on ReadonlySignal<
Whether this string is empty.String> , provided by the StringSignalExtension extensionno setter - isEmpty → bool
-
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> >no setter - isEmpty → bool
-
Available on ReadonlySignal<
Map< , provided by the ReadonlyMapSignalExtension extensionK, V> >no setter - isEven → bool
-
Available on ReadonlySignal<
Returns true if and only if this integer is even.int> , provided by the IntSignalExtension extensionno setter - isFinite → bool
-
Available on ReadonlySignal<
Whether this number is finite.num> , provided by the NumSignalExtension extensionno setter - isInfinite → bool
-
Available on ReadonlySignal<
Whether this number is positive infinity or negative infinity.num> , provided by the NumSignalExtension extensionno setter - isInitialized → bool
-
Check if a signal value is set (does not subscribe)
no setterinherited
- isNaN → bool
-
Available on ReadonlySignal<
Whether this number is a Not-a-Number value.num> , provided by the NumSignalExtension extensionno setter - isNegative → bool
-
Available on ReadonlySignal<
Whether this number is negative.num> , provided by the NumSignalExtension extensionno setter - isNotEmpty → bool
-
Available on ReadonlySignal<
Whether this string is not empty.String> , provided by the StringSignalExtension extensionno setter - isNotEmpty → bool
-
Available on ReadonlySignal<
Map< , provided by the ReadonlyMapSignalExtension extensionK, V> >no setter - isNotEmpty → bool
-
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> >no setter - isOdd → bool
-
Available on ReadonlySignal<
Returns true if and only if this integer is odd.int> , provided by the IntSignalExtension extensionno setter -
iterator
→ Iterator<
E> -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> >no setter -
keys
→ Iterable<
K> -
Available on ReadonlySignal<
Map< , provided by the ReadonlyMapSignalExtension extensionK, V> >no setter - last → E
-
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> >no setter - last → E
-
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> >no setter - length → int
-
Available on ReadonlySignal<
The length of the string.String> , provided by the StringSignalExtension extensionno setter - length → int
-
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> >no setter - length → int
-
Available on ReadonlySignal<
Map< , provided by the ReadonlyMapSignalExtension extensionK, V> >no setter - name → String
-
Available on ReadonlySignal<
The name of the enum value.Enum> , provided by the EnumSignalExtension extensionno setter -
reversed
→ Iterable<
E> -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> >no setter - runes → Runes
-
Available on ReadonlySignal<
An Iterable of Unicode code-points of this string.String> , provided by the StringSignalExtension extensionno setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sign → num
-
Available on ReadonlySignal<
Negative one, zero or positive one depending on the sign and numerical value of this number.num> , provided by the NumSignalExtension extensionno setter - sign → int
-
Available on ReadonlySignal<
Returns the sign of this integer.int> , provided by the IntSignalExtension extensionno setter - sign → double
-
Available on ReadonlySignal<
The sign of the double's numerical value.double> , provided by the DoubleSignalExtension extensionno setter - single → E
-
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> >no setter - sources ↔ Node?
-
getter/setter pairinherited
- value → T
-
Compute the current value
no setter
-
values
→ Iterable<
V> -
Available on ReadonlySignal<
Map< , provided by the ReadonlyMapSignalExtension extensionK, V> >no setter - version ↔ int
-
getter/setter pairinherited
Methods
-
abs(
) → double -
Available on ReadonlySignal<
double> , provided by the DoubleSignalExtension extension -
abs(
) → int -
Available on ReadonlySignal<
Returns the absolute value of this integer.int> , provided by the IntSignalExtension extension -
abs(
) → num -
Available on ReadonlySignal<
The absolute value of this number.num> , provided by the NumSignalExtension extension -
afterCreate(
T val) → void - Internal hook for after a signal is created
-
allMatches(
String string, [int start = 0]) → Iterable< Match> -
Available on ReadonlySignal<
Matches this pattern against the string repeatedly.Pattern> , provided by the PatternSignalExtension extension -
any(
bool test(E element)) → bool -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
asMap(
) → Map< int, E> -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> > -
beforeUpdate(
T val) → void - Internal hook for after a signal is updated
-
call(
) → T -
Return the value when invoked
inherited
-
cast<
R> () → Set< R> -
Available on ReadonlySignal<
Set< , provided by the ReadonlySetSignalExtension extensionE> > -
cast<
R> () → Iterable< R> -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
cast<
RK, RV> () → Map< RK, RV> -
Available on ReadonlySignal<
Map< , provided by the ReadonlyMapSignalExtension extensionK, V> > -
cast<
R> () → List< R> -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> > -
ceil(
) → int -
Available on ReadonlySignal<
Returns the least integer that is not smaller than this number.double> , provided by the DoubleSignalExtension extension -
ceil(
) → int -
Available on ReadonlySignal<
Returnsint> , provided by the IntSignalExtension extensionthis. -
ceil(
) → int -
Available on ReadonlySignal<
The least integer no smaller thannum> , provided by the NumSignalExtension extensionthis. -
ceilToDouble(
) → double -
Available on ReadonlySignal<
Returns the least integer double value no smaller thandouble> , provided by the DoubleSignalExtension extensionthis. -
ceilToDouble(
) → double -
Available on ReadonlySignal<
Returnsint> , provided by the IntSignalExtension extensionthis.toDouble(). -
ceilToDouble(
) → double -
Available on ReadonlySignal<
Returns the least double integer value no smaller thannum> , provided by the NumSignalExtension extensionthis. -
clamp(
num lowerLimit, num upperLimit) → num -
Available on ReadonlySignal<
Returns this num clamped to be in the rangenum> , provided by the NumSignalExtension extensionlowerLimit-upperLimit. -
codeUnitAt(
int index) → int -
Available on ReadonlySignal<
Returns the 16-bit UTF-16 code unit at the givenString> , provided by the StringSignalExtension extensionindex. -
compareTo(
T other) → int -
Available on ReadonlySignal<
Compares this object to another object.T> , provided by the ComparableSignalExtension extension -
contains(
Pattern other, [int startIndex = 0]) → bool -
Available on ReadonlySignal<
Whether this string contains a match ofString> , provided by the StringSignalExtension extensionother. -
contains(
Object? value) → bool -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
containsAll(
Iterable< Object?> other) → bool -
Available on ReadonlySignal<
Set< , provided by the ReadonlySetSignalExtension extensionE> > -
containsKey(
Object? key) → bool -
Available on ReadonlySignal<
Map< , provided by the ReadonlyMapSignalExtension extensionK, V> > -
containsValue(
Object? value) → bool -
Available on ReadonlySignal<
Map< , provided by the ReadonlyMapSignalExtension extensionK, V> > -
difference(
Set< Object?> other) → Set<E> -
Available on ReadonlySignal<
Set< , provided by the ReadonlySetSignalExtension extensionE> > -
dispose(
) → void -
Dispose the signal
override
-
elementAt(
int index) → E -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
endsWith(
String other) → bool -
Available on ReadonlySignal<
Whether this string ends withString> , provided by the StringSignalExtension extensionother. -
every(
bool test(E element)) → bool -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
expand<
R> (Iterable< R> toElements(E element)) → Iterable<R> -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> > -
expand<
R> (Iterable< R> toElements(E element)) → Iterable<R> -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
firstWhere(
bool test(E element), {E orElse()?}) → E -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
firstWhere(
bool test(E element), {E orElse()?}) → E -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> > -
floor(
) → int -
Available on ReadonlySignal<
Returns the greatest integer no greater than this number.double> , provided by the DoubleSignalExtension extension -
floor(
) → int -
Available on ReadonlySignal<
Returnsint> , provided by the IntSignalExtension extensionthis. -
floor(
) → int -
Available on ReadonlySignal<
The greatest integer no greater than this number.num> , provided by the NumSignalExtension extension -
floorToDouble(
) → double -
Available on ReadonlySignal<
Returnsint> , provided by the IntSignalExtension extensionthis.toDouble(). -
floorToDouble(
) → double -
Available on ReadonlySignal<
Returns the greatest double integer value no greater thannum> , provided by the NumSignalExtension extensionthis. -
floorToDouble(
) → double -
Available on ReadonlySignal<
Returns the greatest integer double value no greater thandouble> , provided by the DoubleSignalExtension extensionthis. -
fold<
R> (R initialValue, R combine(R previousValue, E element)) → R -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> > -
fold<
R> (R initialValue, R combine(R previousValue, E element)) → R -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
followedBy(
Iterable< E> other) → Iterable<E> -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
followedBy(
Iterable< E> other) → Iterable<E> -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> > -
forEach(
void action(E element)) → void -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
gcd(
int other) → int -
Available on ReadonlySignal<
Returns the greatest common divisor of this integer andint> , provided by the IntSignalExtension extensionother. -
get(
) → T -
Helper method to get the current value
inherited
-
getRange(
int start, int end) → Iterable< E> -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> > -
indexOf(
E element, [int start = 0]) → int -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> > -
indexOf(
Pattern pattern, [int start = 0]) → int -
Available on ReadonlySignal<
Returns the position of the first match ofString> , provided by the StringSignalExtension extensionpatternin this string, starting atstart, inclusive: -
indexWhere(
bool test(E element), [int start = 0]) → int -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> > -
internalRefresh(
) → bool -
inherited
-
intersection(
Set< Object?> other) → Set<E> -
Available on ReadonlySignal<
Set< , provided by the ReadonlySetSignalExtension extensionE> > -
join(
[String separator = ""]) → String -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
lastIndexOf(
Pattern pattern, [int? start]) → int -
Available on ReadonlySignal<
The starting position of the last matchString> , provided by the StringSignalExtension extensionpatternin this string. -
lastIndexOf(
E element, [int? start]) → int -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> > -
lastIndexWhere(
bool test(E element), [int? start]) → int -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> > -
lastWhere(
bool test(E element), {E orElse()?}) → E -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
lookup(
Object? object) → E? -
Available on ReadonlySignal<
Set< , provided by the ReadonlySetSignalExtension extensionE> > -
map<
R> (R toElement(E e)) → Iterable< R> -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
map<
K2, V2> (MapEntry< K2, V2> convert(K key, V value)) → Map<K2, V2> -
Available on ReadonlySignal<
Map< , provided by the ReadonlyMapSignalExtension extensionK, V> > -
matchAsPrefix(
String string, [int start = 0]) → Match? -
Available on ReadonlySignal<
Matches this pattern against the start ofPattern> , provided by the PatternSignalExtension extensionstring. -
modInverse(
int modulus) → int -
Available on ReadonlySignal<
Returns the modular multiplicative inverse of this integer moduloint> , provided by the IntSignalExtension extensionmodulus. -
modPow(
int exponent, int modulus) → int -
Available on ReadonlySignal<
Returns this integer to the power ofint> , provided by the IntSignalExtension extensionexponentmodulomodulus. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notify(
) → void -
inherited
-
observe(
Widget builder(T), {Key? key, void onInit(T value)?, Function? onValueUpdated, void onAfterBuild(T value)?, void onDispose(T value)?, bool shouldRebuild(T newValue, T oldValue)?, bool shouldNotify(T newValue, T oldValue)?, bool equals(T a, T b)?, Duration? debounce, Duration? throttle, void onError(Object error, StackTrace stack)?, Widget errorBuilder(Object error)?, Widget loadingBuilder()?, String? debugLabel, bool debugPrint = false}) → SignalsWatch< T> -
Available on ReadonlySignal<
Observe this signal and rebuild when it changes.T> , provided by the SignalObserveExtension extension -
onDispose(
void cleanup()) → void Function() -
Add a cleanup function to be called when the signal is disposed
inherited
-
overrideWith(
T val) → Computed< T> - Override the current signal with a new value as if it was created with it
-
padLeft(
int width, [String padding = ' ']) → String -
Available on ReadonlySignal<
Pads this string on the left if it is shorter thanString> , provided by the StringSignalExtension extensionwidth. -
padRight(
int width, [String padding = ' ']) → String -
Available on ReadonlySignal<
Pads this string on the right if it is shorter thanString> , provided by the StringSignalExtension extensionwidth. -
peek(
) → T -
In the rare instance that you have an effect that should write to another signal based on the previous value, but you don't want the effect to be subscribed to that signal, you can read a signals's previous value via
signal.peek().inherited -
readonly(
) → ReadonlySignal< T> - Returns a readonly signal
-
recompute(
) → void - Call the computed function and update the value
-
reduce(
E combine(E value, E element)) → E -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
remainder(
num other) → double -
Available on ReadonlySignal<
double> , provided by the DoubleSignalExtension extension -
remainder(
num other) → num -
Available on ReadonlySignal<
The remainder of the truncating division ofnum> , provided by the NumSignalExtension extensionthisbyother. -
replaceAll(
Pattern from, String replace) → String -
Available on ReadonlySignal<
Replaces all substrings that matchString> , provided by the StringSignalExtension extensionfromwithreplace. -
replaceAllMapped(
Pattern from, String replace(Match match)) → String -
Available on ReadonlySignal<
Replace all substrings that matchString> , provided by the StringSignalExtension extensionfromby a computed string. -
replaceFirst(
Pattern from, String to, [int startIndex = 0]) → String -
Available on ReadonlySignal<
Creates a new string with the first occurrence ofString> , provided by the StringSignalExtension extensionfromreplaced byto. -
replaceFirstMapped(
Pattern from, String replace(Match match), [int startIndex = 0]) → String -
Available on ReadonlySignal<
Replace the first occurrence ofString> , provided by the StringSignalExtension extensionfromin this string. -
replaceRange(
int start, int? end, String replacement) → String -
Available on ReadonlySignal<
Replaces the substring fromString> , provided by the StringSignalExtension extensionstarttoendwithreplacement. -
round(
) → int -
Available on ReadonlySignal<
Returns the integer closest to this number.double> , provided by the DoubleSignalExtension extension -
round(
) → int -
Available on ReadonlySignal<
The integer closest to this number.num> , provided by the NumSignalExtension extension -
round(
) → int -
Available on ReadonlySignal<
Returnsint> , provided by the IntSignalExtension extensionthis. -
roundToDouble(
) → double -
Available on ReadonlySignal<
Returns the integer double value closest todouble> , provided by the DoubleSignalExtension extensionthis. -
roundToDouble(
) → double -
Available on ReadonlySignal<
The double integer value closest to this value.num> , provided by the NumSignalExtension extension -
roundToDouble(
) → double -
Available on ReadonlySignal<
Returnsint> , provided by the IntSignalExtension extensionthis.toDouble(). -
select<
R> (R selector(ReadonlySignal< T> ), {bool? autoDispose = false, String? debugLabel}) → Computed<R> -
Available on ReadonlySignal<
Select a value and return a computed signal to listen for changesT> , provided by the ReadonlySignalUtils extension -
selectObserve<
S> (S selector(dynamic), Widget builder(S), {Key? key, void onInit(S value)?, Function? onValueUpdated, void onAfterBuild(S value)?, void onDispose(S value)?, bool shouldRebuild(S newValue, S oldValue)?, bool shouldNotify(S newValue, S oldValue)?, bool equals(S a, S b)?, Duration? debounce, Duration? throttle, void onError(Object error, StackTrace stack)?, Widget errorBuilder(Object error)?, Widget loadingBuilder()?, String? debugLabel, bool debugPrint = false}) → SignalsWatch< S> -
Available on ReadonlySignal<
Select a specific part of this signal's value and only rebuild when that part changes.T> , provided by the SignalObserveExtension extension -
singleWhere(
bool test(E element), {E orElse()?}) → E -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
skip(
int count) → Iterable< E> -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
skipWhile(
bool test(E value)) → Iterable< E> -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
sorted(
[int compare(E a, E b)?]) → List< E> -
Available on ReadonlySignal<
Return a new array that is sorted by theList< , provided by the ReadonlyListSignalExtension extensionE> >comparefunction -
split(
Pattern pattern) → List< String> -
Available on ReadonlySignal<
Splits the string at matches ofString> , provided by the StringSignalExtension extensionpatternand returns a list of substrings. -
splitMapJoin(
Pattern pattern, {String onMatch(Match)?, String onNonMatch(String)?}) → String -
Available on ReadonlySignal<
Splits the string, converts its parts, and combines them into a new string.String> , provided by the StringSignalExtension extension -
startsWith(
Pattern pattern, [int index = 0]) → bool -
Available on ReadonlySignal<
Whether this string starts with a match ofString> , provided by the StringSignalExtension extensionpattern. -
sublist(
int start, [int? end]) → List< E> -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> > -
subscribe(
void fn(T value)) → void Function() -
Subscribe to value changes with a dispose function
inherited
-
subscribeToNode(
Node node) → void -
inherited
-
substring(
int start, [int? end]) → String -
Available on ReadonlySignal<
The substring of this string fromString> , provided by the StringSignalExtension extensionstart, inclusive, toend, exclusive. -
take(
int count) → Iterable< E> -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
takeWhile(
bool test(E value)) → Iterable< E> -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
toDouble(
) → double -
Available on ReadonlySignal<
This number as a double.num> , provided by the NumSignalExtension extension -
toInt(
) → int -
Available on ReadonlySignal<
Truncates this num to an integer and returns the result as an int.num> , provided by the NumSignalExtension extension -
toJson(
) → dynamic -
Convert value to JSON
inherited
-
toList(
{bool growable = true}) → List< E> -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
toLowerCase(
) → String -
Available on ReadonlySignal<
Converts all characters in this string to lower case.String> , provided by the StringSignalExtension extension -
toRadixString(
int radix) → String -
Available on ReadonlySignal<
Converts this int to a string representation in the givenint> , provided by the IntSignalExtension extensionradix. -
toSet(
) → Set< E> -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
toSigned(
int width) → int -
Available on ReadonlySignal<
Returns the least significantint> , provided by the IntSignalExtension extensionwidthbits of this integer, extending the highest retained bit to the sign. This is the same as truncating the value to fit inwidthbits using an signed 2-s complement representation. The returned value has the same bit value in all positions higher thanwidth. -
toStream(
) → Stream< T> -
Available on ReadonlySignal<
Convert a signal to a Stream to be consumed as a read only stream.T> , provided by the ReadonlySignalUtils extension -
toString(
) → String -
A string representation of this object.
inherited
-
toStringAsExponential(
[int? fractionDigits]) → String -
Available on ReadonlySignal<
An exponential string-representation of this number.num> , provided by the NumSignalExtension extension -
toStringAsFixed(
int fractionDigits) → String -
Available on ReadonlySignal<
A decimal-point string-representation of this number.num> , provided by the NumSignalExtension extension -
toStringAsPrecision(
int precision) → String -
Available on ReadonlySignal<
A string representation withnum> , provided by the NumSignalExtension extensionprecisionsignificant digits. -
toUnsigned(
int width) → int -
Available on ReadonlySignal<
Returns the least significantint> , provided by the IntSignalExtension extensionwidthbits of this integer as a non-negative number (i.e. unsigned representation). The returned value has zeros in all bit positions higher thanwidth. -
toUpperCase(
) → String -
Available on ReadonlySignal<
Converts all characters in this string to upper case.String> , provided by the StringSignalExtension extension -
transform<
R> (R transform(T), {Key? key, required Widget builder(R), void onInit(R value)?, Function? onValueUpdated, void onAfterBuild(R value)?, void onDispose(R value)?, bool shouldRebuild(R newValue, R oldValue)?, bool shouldNotify(R newValue, R oldValue)?, bool equals(R a, R b)?, Duration? debounce, Duration? throttle, void onError(Object error, StackTrace stack)?, Widget errorBuilder(Object error)?, Widget loadingBuilder()?, String? debugLabel, bool debugPrint = false}) → SignalsWatch< R> -
Available on ReadonlySignal<
Transform this signal's value and observe the result with error handling.T> , provided by the SignalObserveExtension extension -
trim(
) → String -
Available on ReadonlySignal<
The string without any leading and trailing whitespace.String> , provided by the StringSignalExtension extension -
trimLeft(
) → String -
Available on ReadonlySignal<
The string without any leading whitespace.String> , provided by the StringSignalExtension extension -
trimRight(
) → String -
Available on ReadonlySignal<
The string without any trailing whitespace.String> , provided by the StringSignalExtension extension -
truncate(
) → int -
Available on ReadonlySignal<
The integer obtained by discarding any fractional digits fromnum> , provided by the NumSignalExtension extensionthis. -
truncate(
) → int -
Available on ReadonlySignal<
Returnsint> , provided by the IntSignalExtension extensionthis. -
truncate(
) → int -
Available on ReadonlySignal<
Returns the integer obtained by discarding any fractional part of this number.double> , provided by the DoubleSignalExtension extension -
truncateToDouble(
) → double -
Available on ReadonlySignal<
Returnsint> , provided by the IntSignalExtension extensionthis.toDouble(). -
truncateToDouble(
) → double -
Available on ReadonlySignal<
Returns the double integer value obtained by discarding any fractional digits from the double value ofnum> , provided by the NumSignalExtension extensionthis. -
truncateToDouble(
) → double -
Available on ReadonlySignal<
Returns the integer double value obtained by discarding any fractional digits fromdouble> , provided by the DoubleSignalExtension extensionthis. -
union(
Set< E> other) → Set<E> -
Available on ReadonlySignal<
Set< , provided by the ReadonlySetSignalExtension extensionE> > -
unsubscribeFromNode(
Node node) → void -
unwatch(
BuildContext context) → void -
Available on ReadonlySignal<
Stop subscriptions to updates on a signal for watchersT> , provided by the FlutterReadonlySignalUtils extension -
watch(
BuildContext context, {String? debugLabel}) → T -
Available on ReadonlySignal<
Rebuild the Element that the current signal is inside ofT> , provided by the FlutterReadonlySignalUtils extension -
where(
bool test(E element)) → Iterable< E> -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> > -
whereType<
R> () → Iterable< R> -
Available on ReadonlySignal<
Iterable< , provided by the ReadonlyIterableSignalExtension extensionE> >
Operators
-
operator %(
num other) → num -
Available on ReadonlySignal<
Euclidean modulo of this number bynum> , provided by the NumSignalExtension extensionother. -
operator %(
num other) → double -
Available on ReadonlySignal<
double> , provided by the DoubleSignalExtension extension -
operator &(
bool other) → bool -
Available on ReadonlySignal<
The logical conjunction ("and") of this andbool> , provided by the BoolSignalExtension extensionother. -
operator &(
int other) → int -
Available on ReadonlySignal<
Bit-wise and operator.int> , provided by the IntSignalExtension extension -
operator *(
num other) → double -
Available on ReadonlySignal<
double> , provided by the DoubleSignalExtension extension -
operator *(
int times) → String -
Available on ReadonlySignal<
Creates a new string by concatenating this string with itself a number of times.String> , provided by the StringSignalExtension extension -
operator *(
num other) → num -
Available on ReadonlySignal<
Multiplies this number bynum> , provided by the NumSignalExtension extensionother. -
operator +(
String other) → String -
Available on ReadonlySignal<
Creates a new string by concatenating this string withString> , provided by the StringSignalExtension extensionother. -
operator +(
List< E> other) → List<E> -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> > -
operator +(
num other) → double -
Available on ReadonlySignal<
double> , provided by the DoubleSignalExtension extension -
operator +(
num other) → num -
Available on ReadonlySignal<
Addsnum> , provided by the NumSignalExtension extensionotherto this number. -
operator -(
num other) → double -
Available on ReadonlySignal<
double> , provided by the DoubleSignalExtension extension -
operator -(
num other) → num -
Available on ReadonlySignal<
Subtractsnum> , provided by the NumSignalExtension extensionotherfrom this number. -
operator /(
num other) → double -
Available on ReadonlySignal<
double> , provided by the DoubleSignalExtension extension -
operator /(
num other) → double -
Available on ReadonlySignal<
Divides this number bynum> , provided by the NumSignalExtension extensionother. -
operator <(
num other) → bool -
Available on ReadonlySignal<
Whether this number is numerically smaller thannum> , provided by the NumSignalExtension extensionother. -
operator <<(
int shiftAmount) → int -
Available on ReadonlySignal<
Shift the bits of this integer to the left byint> , provided by the IntSignalExtension extensionshiftAmount. -
operator <=(
num other) → bool -
Available on ReadonlySignal<
Whether this number is numerically smaller than or equal tonum> , provided by the NumSignalExtension extensionother. -
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator >(
num other) → bool -
Available on ReadonlySignal<
Whether this number is numerically greater thannum> , provided by the NumSignalExtension extensionother. -
operator >=(
num other) → bool -
Available on ReadonlySignal<
Whether this number is numerically greater than or equal tonum> , provided by the NumSignalExtension extensionother. -
operator >>(
int shiftAmount) → int -
Available on ReadonlySignal<
Shift the bits of this integer to the right byint> , provided by the IntSignalExtension extensionshiftAmount. -
operator >>>(
int shiftAmount) → int -
Available on ReadonlySignal<
Bitwise unsigned right shift byint> , provided by the IntSignalExtension extensionshiftAmountbits. -
operator [](
int index) → E -
Available on ReadonlySignal<
List< , provided by the ReadonlyListSignalExtension extensionE> > -
operator [](
Object? key) → V? -
Available on ReadonlySignal<
Map< , provided by the ReadonlyMapSignalExtension extensionK, V> > -
operator [](
int index) → String -
Available on ReadonlySignal<
The character (as a single-code-unit String) at the givenString> , provided by the StringSignalExtension extensionindex. -
operator ^(
int other) → int -
Available on ReadonlySignal<
Bit-wise exclusive-or operator.int> , provided by the IntSignalExtension extension -
operator ^(
bool other) → bool -
Available on ReadonlySignal<
The logical exclusive disjunction ("exclusive or") of this andbool> , provided by the BoolSignalExtension extensionother. -
operator unary-(
) → num -
Available on ReadonlySignal<
The negation of this value.num> , provided by the NumSignalExtension extension -
operator unary-(
) → double -
Available on ReadonlySignal<
double> , provided by the DoubleSignalExtension extension -
operator unary-(
) → int -
Available on ReadonlySignal<
Return the negative value of this integer.int> , provided by the IntSignalExtension extension -
operator |(
int other) → int -
Available on ReadonlySignal<
Bit-wise or operator.int> , provided by the IntSignalExtension extension -
operator |(
bool other) → bool -
Available on ReadonlySignal<
The logical disjunction ("inclusive or") of this andbool> , provided by the BoolSignalExtension extensionother. -
operator ~(
) → int -
Available on ReadonlySignal<
The bit-wise negate operator.int> , provided by the IntSignalExtension extension -
operator ~/(
num other) → int -
Available on ReadonlySignal<
Truncating division operator.num> , provided by the NumSignalExtension extension -
operator ~/(
num other) → int -
Available on ReadonlySignal<
double> , provided by the DoubleSignalExtension extension