Skip to content

Instantly share code, notes, and snippets.

@dotdoom
Created April 1, 2021 14:38
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 dotdoom/cf5c25ec132b748c05c5521101346abd to your computer and use it in GitHub Desktop.
Save dotdoom/cf5c25ec132b748c05c5521101346abd to your computer and use it in GitHub Desktop.
testWidgets('StreamController adding null wtf', (WidgetTester tester) async {
final source = StreamController<String>();
var index = 0;
await tester.pumpWidget(MaterialApp(
home: StreamBuilder(
stream: source.stream,
builder: (context, snapshot) {
index += 1;
return Text('$index');
},
),
));
expect(find.text('1'), findsOneWidget);
source.add('Hello');
await tester.pump();
expect(find.text('2'), findsOneWidget);
source.add('Bye');
await tester.pump();
expect(find.text('3'), findsOneWidget);
source.close();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment