`addObserver` Method is not null safe
michaelspeed opened this issue · comments
The following bug appears while compilation with null safety
Error: Method 'addObserver' cannot be called on 'WidgetsBinding?' because it is potentially null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/Users/michaelspeed/fvm/versions/2.10.4/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
WidgetsBinding.instance.addObserver(this);
To Reproduce
Steps to reproduce the behaviour:
Just start compilation using velocity x in any component
Expected behaviour
To compile
Desktop (please complete the following information):
- OS: mac OS
- Browser: Chrome
- Version: 3.5.1
- Flutter Version: 2.10.4
I don't think it has anything to do with VelocityX. Looks like some other issue @michaelspeed
Have you tried upgrading the Flutter version @michaelspeed ?
I was using 2.10.4
, I will try this with 3.0.1
Yeah let me know if that works otherwise I will push another update with a potential fix
This seems to work on 3.0.1
. Closing this, I guess it will be better to mention which version can be used for flutter 2
and flutter 3
.
Yeah I didn't know that such issue exists with Flutter 2
I want to work on this issue to support both flutter 2 and flutter 3.
when this will be released?