Skip to content

Instantly share code, notes, and snippets.

@erluxman
Created May 15, 2020 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erluxman/cf5626b521d646a779fc9ab9d07aa97b to your computer and use it in GitHub Desktop.
Save erluxman/cf5626b521d646a779fc9ab9d07aa97b to your computer and use it in GitHub Desktop.
The quick StreamBuilder
class ShortStreamBuilder<T> extends StatelessWidget {
const ShortStreamBuilder({@required this.stream, @required this.builder});
final Stream<T> stream;
final AsyncWidgetBuilder<T> builder;
@override
Widget build(BuildContext context) {
return StreamBuilder<T>(
stream: stream,
builder: (context, snapshot) {
if (snapshot.data == null) return Container();
return builder(context, snapshot);
},
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment