A set of widgets to make it more easier to build reactive interfaces.
class Bloc {
// Create a Dart StreamController
StreamController<String> _controller = StreamController<String>();
Stream<String> get stream => _controller.stream;
void dispose() {
_controller.close();
}
}
class Example extends StatelessWidget {
final Bloc bloc;
Example(this.bloc);
@override
Widget build(BuildContext context) {
// Replace this for some ReactiveWidget
//StreamBuilder(
// builder: (BuildContext context, AsyncSnapshot snapshot) {
// if (snapshot.hasError) return Text("Error");
// if (snapshot.hasData) return Text(snapshot.data);
// return Center(
// child: CircularProgressIndicator(),
// );
// },
//);
return ReactiveBuilder(
stream: bloc.stream,
builder: (BuildContext context, data) {
return Text(data);
},
);
}
}