Skip to content

Instantly share code, notes, and snippets.

Created March 31, 2021 04:17
What would you like to do?
Unit Testing a Utility function that returns a Widget (Test)
testWidgets('cant', (tester) async {
when( async => false);
// assert
const mockUrl = 'https://test.test';
Future<void> future(BuildContext context) async {
await Future.delayed(const Duration(seconds: 1));
return htmlContentUtils.launchURL(context, mockUrl);
final widget = providedLocalizedWidgetForTesting(
child: LayoutBuilder(
builder: (context, _) {
return FutureBuilder(
future: future(context),
builder: (ctx, snapshot) {
return const SizedBox.shrink();
await tester.pumpWidget(widget);
await tester.pumpAndSettle();
await tester.pump(const Duration(seconds: 1));
expect(find.byType(Flushbar), findsOneWidget);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment