When our app supports flutter 3, both the compilation speed and the running efficiency will be greatly improved in all aspects. But when we compile, there will be warnings like the following.
1 2 3 |
|
Although the above warning will not affect the compilation of the application, in the long run, it still needs to be solved.
why
The reason is that since flutter 3, SchedulerBinding.instance
returns a non-null instance. When we use SchedulerBinding.instance!.schedulerPhase
, we will get this warning Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null.
How to solve
The solution is very simple, just remove the !
according to the following processing.
1
|
|
What are the scenarios
Starting with flutter3, the following will have compilation warning problems
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
One-click solution
So much content needs to be solved, is there a one-click solution?
If you have been exposed to terminal scripting, the answer is yes. We can handle it using the following shell script.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
implement
1 2 |
|
Note
- The above script is only verified on the mac system, and Linux may need to make simple modifications by itself.
- If the three-party pub contains warning problems, you can choose to upgrade the version corresponding to flutter 3.
This article is reprinted from https://droidyue.com/blog/2022/09/12/fix-flutter-3-warnings-quickly/
This site is for inclusion only, and the copyright belongs to the original author.