diff --git a/packages/flutter_test/lib/src/_matchers_io.dart b/packages/flutter_test/lib/src/_matchers_io.dart index 74a3d49760..0c17612d28 100644 --- a/packages/flutter_test/lib/src/_matchers_io.dart +++ b/packages/flutter_test/lib/src/_matchers_io.dart @@ -60,8 +60,9 @@ class MatchesGoldenFile extends AsyncMatcher { final Uri testNameUri = goldenFileComparator.getTestUri(key, version); Uint8List? buffer; - if (item is Future>) { - buffer = Uint8List.fromList(await item); + if (item is Future?>) { + final List? bytes = await item; + buffer = bytes == null ? null : Uint8List.fromList(bytes); } else if (item is List) { buffer = Uint8List.fromList(item); } diff --git a/packages/flutter_test/test/matchers_test.dart b/packages/flutter_test/test/matchers_test.dart index 7e37125c80..36598dc796 100644 --- a/packages/flutter_test/test/matchers_test.dart +++ b/packages/flutter_test/test/matchers_test.dart @@ -470,6 +470,14 @@ void main() { expect(comparator.imageBytes, equals([1, 2])); expect(comparator.golden, Uri.parse('foo.png')); }); + + testWidgets('future nullable list of integers', + (WidgetTester tester) async { + await expectLater(Future?>.value([1, 2]), matchesGoldenFile('foo.png')); + expect(comparator.invocation, _ComparatorInvocation.compare); + expect(comparator.imageBytes, equals([1, 2])); + expect(comparator.golden, Uri.parse('foo.png')); + }); }); group('does not match', () {