Replies: 2 comments 8 replies
-
What's the difference? class MyWidget extends ... {
final count = signal(0);
final isEven = computed(() => count().isEven);
...
Widget build(BuildContext context) {
return Row(
children: [
Button(child: Text('+'), onPressed: () => count.value++),
Text('$count even=$isEven'),
Button(child: Text('-'), onPressed: () => count.value--),
],
);
}
} The gc should clean up all local fields when the widget gets garbage collected. |
Beta Was this translation helpful? Give feedback.
7 replies
-
would it autoDispose the signal ? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Just a thought I had, but it could be possible to define a watch and signal in the build method:
Same for computed:
Usage could be the following:
What is nice about this is there is no watch widget and the signals are directly tied to the Element.
The only disadvantage is only 1 type of signal can be in the build method without conflicts. This could be fixed with a label possibly.
Beta Was this translation helpful? Give feedback.
All reactions