@@ -13,51 +13,29 @@ typedef RxWidgetBuilder<T> = Widget Function(BuildContext context, T? data);
1313/// Rx stream builder that will pre-populate the streams initial data if the
1414/// given stream is an stream that holds the streams current value such
1515/// as a [ValueStream] or a [ReplayStream]
16- class RxStreamBuilder <T > extends StatelessWidget {
17- final AsyncWidgetBuilder <T > _builder;
18-
19- /// The asynchronous computation to which this builder is currently connected,
20- /// possibly null. When changed, the current summary is updated using
21- /// [afterDisconnected] , if the previous stream was not null, followed by
22- /// [afterConnected] , if the new stream is not null.
23- final Stream <T > stream;
24-
25- /// The data that will be used to create the initial snapshot.
26- ///
27- /// Providing this value (presumably obtained synchronously somehow when the
28- /// [Stream] was created) ensures that the first frame will show useful data.
29- /// Otherwise, the first frame will be built with the value null, regardless
30- /// of whether a value is available on the stream: since streams are
31- /// asynchronous, no events from the stream can be obtained before the initial
32- /// build.
33- final T ? initialData;
34-
16+ class RxStreamBuilder <T > extends StreamBuilder <T > {
3517 /// Creates a new [RxStreamBuilder] that builds itself based on the latest
3618 /// snapshot of interaction with the specified [stream] and whose build
3719 /// strategy is given by [builder] .
3820 ///
3921 /// The [initialData] is used to create the initial snapshot.
22+ /// See [StreamBuilder.initialData] .
4023 ///
4124 /// The [builder] must not be null. It must only return a widget and should not have any side
4225 /// effects as it may be called multiple times.
4326 RxStreamBuilder ({
4427 Key ? key,
4528 required RxWidgetBuilder <T > builder,
46- required this . stream,
47- this . initialData,
29+ required Stream < T > stream,
30+ T ? initialData,
4831 }) : assert (builder != null ),
4932 assert (stream != null ),
50- _builder = _createStreamBuilder <T >(builder),
51- super (key: key);
52-
53- @override
54- Widget build (BuildContext context) {
55- return StreamBuilder <T >(
56- initialData: getInitialData (initialData, stream),
57- builder: _builder,
58- stream: stream,
59- );
60- }
33+ super (
34+ key: key,
35+ initialData: getInitialData (initialData, stream),
36+ builder: _createStreamBuilder <T >(builder),
37+ stream: stream,
38+ );
6139
6240 /// Get latest value from stream or return `null` .
6341 @visibleForTesting
0 commit comments