flutter_rx_stream_builder 1.0.3

flutter_rx_stream_builder #

A new Flutter package project.

Getting Started #

An rx stream builder widget that is able to pre-populate a flutter StreamBuilder with data from an rx stream if the stream is either a value or a replay observable. For example the RX stream is a BehaviorSubject or a ReplaySubject.

This will slightly improve the performance as the first frame will be rendered with data rather than waiting for the stream to emit data.

A normal dart stream can also be passed to this widget and it will behave exactly the same way as a normal Flutter StreamBuilder

Widget build(BuildContext context) {
  return RxStreamBuilder<String>(
      stream: BehaviorSubject<String>.seeded("Hello"),
      builder: (context, snapshot) => Text(snapshot.data),

For a more complex example see the example project

The below changes the applications theme every two seconds

import 'package:flutter/material.dart';
import 'dart:math' as math;
import 'package:rxdart/rxdart.dart';
import 'package:flutter_rx_stream_builder/flutter_rx_stream_builder.dart';

class RandomThemeManager {
  final Subject<ThemeData> _themeData = BehaviorSubject.seeded(
      ThemeData.light().copyWith(primaryColor: Colors.yellow));

  Observable<ThemeData> get themeData => _themeData;

  void initialise() {
    Observable.fromIterable(Iterable.generate(5000, (n) => n))
        .interval(const Duration(seconds: 2))
        .map((_) => ThemeData.light().copyWith(
                Color((math.Random().nextDouble() * 0xFFFFFF).toInt() << 0)
        .listen((theme) => _themeData.add(theme));

void main() {
  final themeManager = RandomThemeManager();

class MyApp extends StatelessWidget {
  final Observable<ThemeData> _themeData$;

  const MyApp(this._themeData$, {Key key}) : super(key: key);

  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return RxStreamBuilder(
      stream: _themeData$,
      builder: (context, snapshot) => MaterialApp(
            title: 'RxStreamBuilder Demo',
            theme: snapshot.data,
            home: MyHomePage(title: 'Rx StreamBuilder Demo Page'),

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  _MyHomePageState createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
              'You have pushed the button this many times:',
              style: Theme.of(context).textTheme.display1,
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),

[1.0.3] - 18/12/2019

  • Updated to adhere with new names in RxDart

[1.0.2] - 21/08/2019

  • Fixed issue getting initial data of ReplaySubject with no value in value collection

[1.0.1] - 01/07/2019

  • Added ability to define snapshot index in the case where a ReplayObservable is passed in and may have a collection of values accessible

[1.0.0] - 28/06/2019

  • Initial release


example #

A simple project that uses RxStreamBuilder to prime the stream builder with initial data from a BehaviorSubject.

The application simple changes the theme every two seconds.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_rx_stream_builder: ^1.0.3

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_rx_stream_builder/flutter_rx_stream_builder.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
flutter 0.0.0
rxdart >=0.23.0 <1.0.0 0.23.1
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
pedantic any