Created
May 15, 2020 03:37
-
-
Save erluxman/cf5626b521d646a779fc9ab9d07aa97b to your computer and use it in GitHub Desktop.
The quick StreamBuilder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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