Closed Kiwi-KiwiCorp closed 1 year ago
Hi @Kiwi-KiwiCorp ! Thanks for this discussion! So, in the moment you need to nest two builders inside each other. I thing your suggestion interesting. I'll be thinking of a solution for this following the line of what we already have in 'Cubes'. But i see no problem in nest two builders inside each other like this:
cube.firstObs.build((value1){
return Column(
children:[
Text('Hello $value1'),
cube.secondObs.build((value2){
return Text('My Ocupation is $value2'),
}),
]
);
});
If i follow exactly you suggestion. this packager will is equal flutter_bloc. And this is not my idea.
You can use state
approach too:
class MyState {
final int count;
MyState(this.count);
MyState.initial({this.count = 0});
MyState copyWith({int? count}){
return MyState(count ?? this.count);
}
}
class MyCube extends Cube{
final state = MyState.initial().obs;
}
class View extends CubeWidget<MyCube> {
const View({Key? key}) : super(key: key);
@override
Widget buildView(BuildContext context, MyCube cube) {
return cube.state.build((MyState state){
return Column(
children: [
const Text('Your count is:'),
Text(state.count.toString()),
],
);
});
}
}
let's say I had a class and in that class, I had the following fields:
is there a way I could listen to both/all fields for a change? or would I need to nest two builders inside each other currently? I think a good syntax for rebuilding based on any field changing would be:
and then the syntax for specifying multiple fields to listen to could be something like this:
you might actually have to specify the fields something like this unless you can figure out a way to do it using the above syntax:
I think this addition would make cubes much more versatile.