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

Method 'addObserver' cannot be called on 'WidgetsBinding?' because it is potentially null. #158

Closed
abhihasabe opened this issue Aug 4, 2022 · 4 comments

Comments

@abhihasabe
Copy link

/C:/flutter/.pub-cache/hosted/pub.dartlang.org/velocity_x-3.5.1/lib/src/flutter/common/velocity_ensure_visible.dart:67:29: Error: Method 'addObserver' cannot be called on 'WidgetsBinding?' because it is potentially null.

  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/binding.dart').
    Try calling using ?. instead.
    WidgetsBinding.instance.addObserver(this);
    ^^^^^^^^^^^
    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/velocity_x-3.5.1/lib/src/flutter/common/velocity_ensure_visible.dart:72:29: Error: Method 'removeObserver' cannot be called on 'WidgetsBinding?' because it is potentially null.
  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/binding.dart').
    Try calling using ?. instead.
    WidgetsBinding.instance.removeObserver(this);
    ^^^^^^^^^^^^^^
    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/velocity_x-3.5.1/lib/src/flutter/drawer.dart:150:29: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/binding.dart').
    Try calling using ?. instead.
    WidgetsBinding.instance.addPostFrameCallback(getBoxHeight);
    ^^^^^^^^^^^^^^^^^^^^
    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/velocity_x-3.5.1/lib/src/flutter/marquee.dart:51:29: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/binding.dart').
    Try calling using ?. instead.
    WidgetsBinding.instance.addPostFrameCallback((callback) {
    ^^^^^^^^^^^^^^^^^^^^
    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/velocity_x-3.5.1/lib/src/flutter/popup_menu.dart:186:29: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/binding.dart').
    Try calling using ?. instead.
    WidgetsBinding.instance.addPostFrameCallback((call) {
    ^^^^^^^^^^^^^^^^^^^^

FAILURE: Build failed with an exception.

  • Where:
    Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1102

  • What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 30s
Exception: Gradle task assembleDebug failed with exit code 1

@adomiciliooapp
Copy link

Hi, I have the same bug, any news?

@iampawan
Copy link
Owner

Which flutter version you are using @adomiciliooapp, @abhihasabe ?

@elkana
Copy link

elkana commented Oct 25, 2022

this is known issue when using flutter before 3.
downgrade to version 3.4.0 for temporary solution

@iampawan
Copy link
Owner

Fixed in 3.6.0

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

No branches or pull requests

4 participants