diegoveloper / flutter_percent_indicator

Flutter percent indicator library
BSD 2-Clause "Simplified" License
679 stars 206 forks source link

app is not running, because of WidgetsBinding?.instance.addPostFrameCallback((_) #164

Closed guvanch-amangeldiyev closed 2 years ago

guvanch-amangeldiyev commented 2 years ago

Launching lib/main.dart on iPhone 13 in debug mode... lib/main.dart:1 Xcode build done. 13,1s Failed to build iOS app Error output from Xcode build: ↳ objc[9671]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1e5f16b90) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x103e882c8). One of the two will be used. Which one is undefined. objc[9671]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1e5f16be0) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x103e88318). One of the two will be used. Which one is undefined. BUILD FAILED Xcode's output: ↳ Writing result bundle at path: /var/folders/_q/9swcthyx13l07kyknkj99xc40000gn/T/flutter_tools.68NsIg/flutter_ios_build_temp_dir2Wtmw2/temporary_xcresult_bundle : Warning: The class 'WidgetsBinding' cannot be null. ../…/lib/linear_percentindicator.dart:162 Try replacing '?.' with '.' WidgetsBinding?.instance.addPostFrameCallback(() { ^^^^^^^^^^^^^^ : Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null. ../…/lib/linear_percent_indicator.dart:162

lines ../…/lib/linear_percent_indicator.dart:162 ../…/lib/linear_percent_indicator.dart:162

[✓] Flutter (Channel stable, 2.10.1, on macOS 12.1 21C52 darwin-arm) [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.1) [✓] VS Code (version 1.67.1) [✓] VS Code (version 1.64.2) [✓] Connected device (2 available) [✓] HTTP Host Availability

• No issues found!

keitokusano commented 2 years ago

Facing the same problem.

diegoveloper commented 2 years ago

Please see the closed issues.

On Sat, May 14, 2022, 5:51 AM keito @.***> wrote:

Facing the same problem.

— Reply to this email directly, view it on GitHub https://github.com/diegoveloper/flutter_percent_indicator/issues/164#issuecomment-1126690338, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFL3UGJ6ZON56NWNJPNCKLVJ6AT5ANCNFSM5V5MMNUA . You are receiving this because you are subscribed to this thread.Message ID: @.*** com>

zky6628 commented 2 years ago

I temporarily solved the problem with version 4.0.1. 4.0.1 code :

WidgetsBinding.instance?.addPostFrameCallback((_) { if (mounted) { setState(() { _containerWidth = _containerKey.currentContext?.size?.width ?? 0.0; _containerHeight = _containerKey.currentContext?.size?.height ?? 0.0; if (_keyIndicator.currentContext != null) { _indicatorWidth = _keyIndicator.currentContext?.size?.width ?? 0.0; _indicatorHeight = _keyIndicator.currentContext?.size?.height ?? 0.0; } }); } });