buildFromStream method

Widget buildFromStream({
  1. DataServiceWidgetBuilder<X>? builder,
  2. dynamic key,
  3. bool isSliver = false,
  4. bool crossFade = true,
  5. bool allowNull = false,
  6. SimpleWidgetBuilder loading = kLoader,
})

Implementation

Widget buildFromStream(
    {DataServiceWidgetBuilder<X>? builder,
    key,
    bool isSliver = false,
    bool crossFade = true,
    bool allowNull = false,
    SimpleWidgetBuilder loading = kLoader}) {
  final service = this;
  return StreamBuilder<X>(
    key: key is Key ? key : Key("${X}${key ?? 'StreamBuilder'}"),
    stream: service.stream
        .asBroadcastStream()
        .where((event) => event != null)
        .cast(),
    builder: (context, snapshot) => snapshot.render(
      context,
      isSliver: isSliver,
      crossFade: crossFade,
      allowNull: allowNull,
      successFn: (X data) {
        return builder!(data, service);
      },
      loadingFn: loading,
    ),
    initialData: this.currentValue,
  );
}