You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, I was doing some tests using your excellent package, and I noticed a very weird bug. Basically, I have one widget watching a Computed reference which itself is based on a State reference. Each time the button is pressed, the state is updated and the other reference is re-computed. So far so good.
However, the widget is not systematically rebuilt. It only works half the time, randomly. Yet, the value returned by the Computed is definitely different!
Peek.2021-05-30.16-21.mp4
import'package:binder/binder.dart';
import'package:flutter/cupertino.dart';
import'package:flutter/material.dart';
voidmain() =>runApp(BinderScope(child:AppView()));
classAppViewextendsStatelessWidget {
@overrideWidgetbuild(BuildContext context) {
returnMaterialApp(
home:Column(
mainAxisAlignment:MainAxisAlignment.center,
children: [
RaisedButton(
child:Text("Press me"),
onPressed: () => context.use(testLogicRef).click(),
),
Builder(
builder: (context) {
final val = context.watch(computedValRef);
print("Rebuilt with: $val");
returnText("$val");
},
)
],
),
);
}
}
final testLogicRef =LogicRef((scope) =>TestLogic(scope));
final testStateRef =StateRef(0);
final computedValRef =Computed<int>((watch) {
final val =watch(testStateRef);
final computedVal =DateTime.now().millisecondsSinceEpoch;
print("Computed value: $computedVal");
return computedVal;
});
classTestLogicwithLogic {
constTestLogic(this.scope);
@overridefinalScope scope;
voidclick() =>update(testStateRef, (int val) => val +1);
}
It drives me crazy. Am I doing something wrong?
Also, note that when I press the button once, the Computed is called twice or thrice. Is that expected?
I'm using Binder 0.4.0 with Flutter 2.0.6 and Dart 2.12.3.
Hey @letsar!
So, I was doing some tests using your excellent package, and I noticed a very weird bug. Basically, I have one widget watching a
Computedreference which itself is based on aStatereference. Each time the button is pressed, the state is updated and the other reference is re-computed. So far so good.However, the widget is not systematically rebuilt. It only works half the time, randomly. Yet, the value returned by the
Computedis definitely different!Peek.2021-05-30.16-21.mp4
It drives me crazy. Am I doing something wrong?
Also, note that when I press the button once, the
Computedis called twice or thrice. Is that expected?I'm using Binder 0.4.0 with Flutter 2.0.6 and Dart 2.12.3.