buildWithContext method

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

Implementation

Widget buildWithContext(
    {DataServiceWidgetBuilderWithContext<X?>? builder,
    String? key,
    bool allowNull = false,
    bool isSliver = false,
    bool crossFade = true,
    SimpleWidgetBuilder? loading}) {
  final service = this;
  return StreamBuilder<X>(
    key: Key("${X}${key ?? 'StreamBuilder'}"),
    stream: service.stream.where((event) => event != null).cast(),
    initialData: service.currentValue,
    builder: (context, snapshot) => snapshot.render(
      context,
      allowNull: allowNull,
      crossFade: crossFade,
      isSliver: isSliver,
      builder: (input, loader) {
        if (input != null || allowNull) {
          return builder!(context, input, service);
        } else {
          return loader();
        }
      },
      // successFn: (X data) {
      //   return builder!(context, data, service);
      // },
    ),
  );
}