Skip to content

WidgetsBinding.instance.window.frameData.frameNumber throws in tests #105530

@dnfield

Description

@dnfield
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  testWidgets('frameData', (WidgetTester tester) async {
    print(WidgetsBinding.instance.window.frameData.frameNumber);
  });
}

throws:

00:02 +0: frameData                                                                                                                                                                                       
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following _TypeError was thrown running a test:
type 'Null' is not a subtype of type 'FrameData'

When the exception was thrown, this was the stack:
#0      TestWindow.frameData (dart:ui/window.dart:687:17)
#1      main.<anonymous closure> (file:///Users/dnfield/src/flutter/flutter.widgets/packages/visibility_detector/test/window_test.dart:6:42)
#2      testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:171:29)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

The test description was:
  frameData
════════════════════════════════════════════════════════════════════════════════════════════════════
00:02 +0 -1: frameData [E]                                                                                                                                                                                
  Test failed. See exception logs above.
  The test description was: frameData
  
00:02 +0 -1: Some tests failed.             

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our testsframeworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions