Created
April 9, 2020 20:56
-
-
Save fedotxxl/da439dffb8bcbd63315e5f1f76fac85f to your computer and use it in GitHub Desktop.
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
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