Home > OS >  error G7AD6136F: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?&#
error G7AD6136F: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?&#

Time:08-21

am running my desktop application using flutter 2.10.0 and am getting this error type.

following is my flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.0, on Microsoft Windows [Version 10.0.19044.1766], 
locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.6)
[√] Android Studio (version 2021.2)
[√] IntelliJ IDEA Community Edition (version 2021.3)
[√] VS Code, 64-bit edition (version 1.69.2)
[√] Connected device (4 available)
[√] HTTP Host Availability

• No issues found!

the error is as follows:

 20.1.58/lib/src/calendar/sfcalendar.dart(2867,31): error G7AD6136F: Method 
'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null. [E:\SPACING\marmanet\Forest-Inventory-Desktop-master\Forest-Inventory-Desktop-master\build\windows\flutter\flutter_assemble.vcxproj]
/C:/scr/flutter/.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_calendar-20.1.58/lib/src/calendar/sfcalendar.dart(4157,35): error G7AD6136F: Method 'addPostFrameCallback' cannot be called on 'SchedulerBinding?' because it is potentially null. [E:\SPACING\marmanet\Forest-Inventory-Desktop-master\Forest-Inventory-Desktop-master\build\windows\flutter\flutter_assemble.vcxproj]
/C:/scr/flutter/.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_calendar-20.1.58/lib/src/calendar/sfcalendar.dart(4176,37): error G7AD6136F: Method 'addPostFrameCallback' cannot be called on 'SchedulerBinding?' because it is potentially null. [E:\SPACING\marmanet\Forest-Inventory-Desktop-master\Forest-Inventory-Desktop-master\build\windows\flutter\flutter_assemble.vcxproj]
/C:/scr/flutter/.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_calendar-20.1.58/lib/src/calendar/sfcalendar.dart(4322,33): error G7AD6136F: Method 'addPostFrameCallback' cannot be called on 'SchedulerBinding?' because it is potentially null. [E:\SPACING\marmanet\Forest-Inventory-Desktop-master\Forest-Inventory-Desktop-master\build\windows\flutter\flutter_assemble.vcxproj] 

here is also part of my pubspec.yaml file:

   sdk: ">=2.12.0 <3.0.0"

   dependencies:
   flutter_test:
    sdk: flutter
    flutter:
    sdk: flutter
    flutter_localizations:
    sdk: flutter
    url_launcher: ^6.0.2
    path_provider: ^2.0.1
    path_provider_macos: ^2.0.0
    desktop_window: 0.4.0
  
  
    syncfusion_localizations: ^20.1.47
    syncfusion_flutter_datagrid_export: ^20.1.47-beta
    syncfusion_flutter_calendar: ^20.1.47
    syncfusion_flutter_datepicker: ^20.1.47
    syncfusion_flutter_charts: ^20.1.47
    syncfusion_flutter_gauges: ^20.1.47
    syncfusion_flutter_sliders: ^20.1.47
    syncfusion_flutter_pdf: ^20.1.47-beta
    syncfusion_flutter_barcodes: ^20.1.47
    syncfusion_officechart: ^20.1.47-beta
    syncfusion_flutter_maps: ^20.1.47
    syncfusion_flutter_signaturepad: ^20.1.47
    syncfusion_flutter_pdfviewer: ^20.1.47-beta
    syncfusion_flutter_treemap: ^20.1.47-beta
    cloud_firestore: ^3.2.1
    firebase_core: ^1.19.1`

I have tried many options without valid output, what might the problem?

CodePudding user response:

You can include '?'

WidgetsBinding.instance?.addPostFrameCallback((timeStamp) { })

But I recommend the upgrade, the flutter.

For upgrade do flutter upgrade, use the latest version packages and you can use like bellow on current version

WidgetsBinding.instance.addPostFrameCallback((timeStamp) { })

CodePudding user response:

This is a bug in the syncfusion_flutter_calendar package; they released a version that uses code that only works in Flutter 3.0 or later, but didn't set the package's minimum version to Flutter 3.0.

You can work around it by either upgrading to Flutter 3.0 or using a version of the package from before they made that incompatible change, but you should also report it to the developers of the package.

  • Related