Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null

Tags:

flutter

dart

After updating Flutter 3.0 below compile error occured. This error has no ref to my code. It refers to framework.

Launching lib/main.dart on Chrome in debug mode...
lib/main.dart:1
: Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null.
../…/src/framework.dart:275
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('../snap/flutter/common/flutter/packages/flutter/lib/src/scheduler/binding.dart').
package:flutter/…/scheduler/binding.dart:1
    if (SchedulerBinding.instance!.schedulerPhase ==
like image 568
isa Avatar asked Sep 12 '25 12:09

isa


1 Answers

It's expected when you migrate to Flutter 3.0. The docs also mention about this:

Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null.

These are caused by a simplification of the API (the instance property on bindings is now non-nullable), combined with an eager compiler that wants to report any case where redundant null-aware operators (such as ! and ?.) that are used when they’re not necessary.

Solutions:

  1. You can update your packages by running flutter pub upgrade.

  2. If the issue persist, (say, some of the packages are still giving you this error), you can either ignore it as this is just a warning or simply edit the source file and remove ? and/or !.

like image 78
CopsOnRoad Avatar answered Sep 15 '25 04:09

CopsOnRoad