-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Description
to reproduce use any example use of SignalProvider
i.e https://dartsignals.dev/flutter/signal-provider/
as the title says it's so self explainatory
however in this example
class Counter extends FlutterSignal<int> {
Counter([super.value = 0]);
void increment() => value++;
}
class Example extends StatelessWidget {
const Example({super.key});
@override
Widget build(BuildContext context) {
return SignalProvider<Counter>(
create: () => Counter(),
child: Scaffold(...)
);
}the create function always creates a new instance of the Counter object causing a new signal to be created every time !
after long trials the only thing i managed to do is to store it in a variable
class Counter extends FlutterSignal<int> {
Counter([super.value = 0]);
void increment() => value++;
}
final counter = Counter();
class Example extends StatelessWidget {
const Example({super.key});
@override
Widget build(BuildContext context) {
return SignalProvider<Counter>(
create: () => counter,
child: Scaffold(...)
);
}this prevents the behavior but trials to be done to find other unexpected behaviours for the lifecycle
Metadata
Metadata
Assignees
Labels
No labels