apgapg / pie_chart

Flutter Pie chart with animation
https://pub.dev/packages/pie_chart
MIT License
179 stars 85 forks source link

Flutter 3 issue #82

Open fennelhans opened 2 years ago

fennelhans commented 2 years ago

In Flutter 3, WidgetsBinding.instance no longer requires a null safety check.

: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
../…/pie_chart/pie_chart.dart:42
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../../bin/flutter/packages/flutter/lib/src/widgets/binding.dart').
package:flutter/…/widgets/binding.dart:1
    WidgetsBinding.instance?.addPostFrameCallback((_) {
fennelhans commented 2 years ago

This is how other teams are solving it: (WidgetsBinding.instance as WidgetsBinding).addObserver(this);

apgapg commented 2 years ago

Thanks for help @fennelhans . Shall fix soon

apgapg commented 2 years ago

I tried running example app on flutter 3.0.1 but couldn't find any issue.

mahoraz commented 2 years ago

I tried running example app on flutter 3.0.1 but couldn't find any issue.

they changed WidgetBinding.instance null-aware checking operator issue into a warning (it was classified as an exception during build with flutter 3.0.0 and would prevent compilation before 3.0.1). It still shows up as a warning during debug


: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
../…/pie_chart/pie_chart.dart:42
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../../Documents/flutter/packages/flutter/lib/src/widgets/binding.dart').
package:flutter/…/widgets/binding.dart:1
    WidgetsBinding.instance?.addPostFrameCallback((_) {
                   ^
apgapg commented 2 years ago

Pie chart doesnt use WidgetsBinding. I dont see any warning when running project locally on latest flutter