NourEldinShobier / pmvvm

A clean & simple MVVM solution for state management using Provider package.
MIT License
53 stars 6 forks source link

Null aware operator used on non null able type warning when running #13

Closed rurickdev closed 2 years ago

rurickdev commented 2 years ago

After updating to flutter 3.0 I'm getting a warning about a null aware operator used on a non null type

Here is the warning

: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
../…/lib/mvvm_builder.widget.dart:47
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../fvm/versions/stable/packages/flutter/lib/src/widgets/binding.dart').
package:flutter/…/widgets/binding.dart:1
    WidgetsBinding.instance?.addObserver(this);
                   ^
: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
../…/lib/mvvm_builder.widget.dart:48
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../fvm/versions/stable/packages/flutter/lib/src/widgets/binding.dart').
package:flutter/…/widgets/binding.dart:1
    WidgetsBinding.instance?.addPostFrameCallback((_) => _vm.onMount());

                   ^
: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
../…/lib/mvvm_builder.widget.dart:78
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../fvm/versions/stable/packages/flutter/lib/src/widgets/binding.dart').
package:flutter/…/widgets/binding.dart:1
    WidgetsBinding.instance?.removeObserver(this);
                   ^

I just write this PR to solve that following that WidgetsBinding.instance is not null able docs

NourEldinShobier commented 2 years ago

Hi @rurickdev great work my friend

The PR has been approved