streamBuilder<T> method
StreamBuilder<T>
streamBuilder<T>(
- T map(
- S
- Key? key,
- T? initialState,
- bool log = false,
- required AsyncWidgetBuilder<
T> builder,
Implementation
StreamBuilder<T> streamBuilder<T>(
T Function(S) map, {
Key? key,
T? initialState,
bool log = false,
required AsyncWidgetBuilder<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("------ streamBuilder.equals $one $two ${one == two}");
}
return one == two;
}),
builder: (
BuildContext context,
AsyncSnapshot<T> snapshot,
) {
if (log) {
Fimber.d("------ streamBuilder ${snapshot.data ?? initialData}");
}
return builder(context, snapshot);
},
);
}