easy_web_view
easy_web_view copied to clipboard
Compile-time Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
I just added this plugin to a Flutter Web project, but when I compile it I get
../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/webview_windows-0.1.9/lib/src/webview.dart:481:29: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../dev/flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
WidgetsBinding.instance.addPostFrameCallback((_) => _reportSurfaceSize());
^^^^^^^^^^^^^^^^^^^^
Failed to compile application.
Not sure what's going on here.
The project itself is not null-safe, but as far as I know it should still be possible to use null safe plugins?
Note that the error message points to webview_windows
, but this is a Flutter Web project.
I have this error too using easy_web_view 1.6.0. I am ONLY compiling for web. No windows, ios, android app etc. Why is it referring to webview_windows?? I am also running with unsound null safety as I am in the middle of updating an old project to null safety.
I have just updated my project to null safety and I still have the same problem. PS using flutter version 2.10.3
Hi @magnuswikhog @icecandy This is an issue with flutter 3 kindly downgrade the easy web view plugin or better still migrate the project to null safety and modify your code to this
WidgetsBinding.instance!.addPostFrameCallback((_) => _reportSurfaceSize());
@Yczar Not sure if I understand you correctly - I got the error on Flutter 2.8.1...