stateBuilder<T> method
StreamBuilder<T>
stateBuilder<T>(
- T map(
- S
- Key? key,
- T? initialState,
- bool log = false,
- required AsyncWidgetBuilderKokoro<
T> builder,
Implementation
StreamBuilder<T> stateBuilder<T>(
T Function(S) map, {
Key? key,
T? initialState,
bool log = false,
required AsyncWidgetBuilderKokoro<T> builder,
}) {
final initialData = initialState ?? map(currentState);
return StreamBuilder<T>(
key: key,
initialData: initialData,
stream: state.map(map).distinct((one, two) {
if (log) {
Fimber.d("------ stateBuilder.equals $one $two ${one == two}");
}
return one == two;
}),
builder: (
BuildContext context,
AsyncSnapshot<T> snapshot,
) {
if (log) {
Fimber.d("------ stateBuilder ${snapshot.data ?? initialData}");
}
return builder(context, snapshot.data ?? initialData);
},
);
}