import 'package:flutter/material.dart'; import 'package:rxdart/rxdart.dart'; class ValueStreamBuilder extends StreamBuilder { ValueStreamBuilder({ super.key, ValueStream? stream, required super.builder, }) : super( stream: stream, initialData: stream?.value, ); } class ValueStreamBuilderEx extends StreamBuilder { ValueStreamBuilderEx({ super.key, ValueStream? stream, required StreamWidgetBuilder builder, }) : super( stream: stream, initialData: stream?.value, builder: builder.snapshotBuilder ?? (context, snapshot) { return builder.valueBuilder!(context, snapshot.requireData); }, ); } class StreamWidgetBuilder { const StreamWidgetBuilder._({ this.snapshotBuilder, this.valueBuilder, }); const StreamWidgetBuilder.snapshot(AsyncWidgetBuilder builder) : this._(snapshotBuilder: builder); const StreamWidgetBuilder.value( Widget Function(BuildContext context, T value) builder) : this._(valueBuilder: builder); final AsyncWidgetBuilder? snapshotBuilder; final Widget Function(BuildContext context, T value)? valueBuilder; }