Skip to content

Instantly share code, notes, and snippets.

@fedotxxl
Created April 9, 2020 20:56
Show Gist options
  • Save fedotxxl/da439dffb8bcbd63315e5f1f76fac85f to your computer and use it in GitHub Desktop.
Save fedotxxl/da439dffb8bcbd63315e5f1f76fac85f to your computer and use it in GitHub Desktop.
import 'package:flutter/widgets.dart';
class MyStreamBuilder<T> extends StatelessWidget {
final T initialData;
final AsyncWidgetBuilder<T> builder;
final Stream<T> stream;
const MyStreamBuilder({
Key key,
this.initialData,
this.stream,
@required this.builder,
});
@override
Widget build(BuildContext context) {
return StreamBuilder<T>(
key: this.key,
initialData: this.initialData,
stream: this.stream,
builder: (context, snapshot) {
if (snapshot.hasError) {
if (snapshot.error is Error) {
print((snapshot.error as Error).stackTrace);
} else {
print(snapshot.error);
}
}
return this.builder(context, snapshot);
},
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment