VelocityX icon indicating copy to clipboard operation
VelocityX copied to clipboard

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

Open abhihasabe opened this issue 2 years ago • 2 comments

/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

abhihasabe avatar Aug 04 '22 19:08 abhihasabe

Hi, I have the same bug, any news?

adomiciliooapp avatar Aug 29 '22 10:08 adomiciliooapp

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

iampawan avatar Oct 11 '22 13:10 iampawan

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

elkana avatar Oct 25 '22 05:10 elkana

Fixed in 3.6.0

iampawan avatar Oct 26 '22 12:10 iampawan