Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HtmlDocument's visibilityState is String? when compiling tests. #93

Open
harkairt opened this issue Jan 15, 2024 · 0 comments
Open

HtmlDocument's visibilityState is String? when compiling tests. #93

harkairt opened this issue Jan 15, 2024 · 0 comments

Comments

@harkairt
Copy link

harkairt commented Jan 15, 2024

Please refer to this repository: https://github.com/harkairt/test_compile_error
especially this line

Steps:

  • clone the repository
  • fvm use (or simply use a global flutter 3.16.5)
  • flutter pub get && flutter run -d 'chrome'
    • works well, the app runs, and if you switch to a new tab, the proper message is written to debug console
  • flutter test
    • Error: Method 'toTabVisibilityChangeEvent' cannot be called on 'String?' because it is potentially null. Try calling using ?. instead.
    • if you switch out the commenting of these two lines
      final event = document.visibilityState.toTabVisibilityChangeEvent();
      // final event = (document.visibilityState ?? '').toTabVisibilityChangeEvent();
  • then executing the test again will succeed ✅

note: the IDE will warn about unnecessary fallback '' since it recognizes visibilityState to be String and not String?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant