benjamindean / flutter_vibration

Handle vibration on iOS and Android in Flutter apps
217 stars 67 forks source link

Web App Does Not Work After Upgrading To 1.7.4 #72

Closed imariman closed 1 year ago

imariman commented 1 year ago

I am getting an error at VibrationWebPlugin.registerWith after upgrading to v1.7.4. Once I remove vibration package from pubspec, web app starts to work without any problem. Error log is below.

Flutter Web Bootstrap: Auto Error: Binding has not yet been initialized. The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized. Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method.
The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After calling that method, the "instance" getter will return the binding. In a test, one can call "TestWidgetsFlutterBinding.ensureInitialized()" as the first line in the test's "main()" method to initialize the binding. If ServicesBinding is a custom binding mixin, there must also be a custom binding class, like WidgetsFlutterBinding, but that mixes in the selected binding, and that is the class
that must be constructed before using the "instance" getter. at Object.throw_ [as throw] (http://localhost:8080/dart_sdk.js:5080:11) at http://localhost:8080/packages/flutter/src/foundation/binding.dart.lib.js:81:21 at BindingBase.checkInstance (http://localhost:8080/packages/flutter/src/foundation/binding.dart.lib.js:103:26) at get instance [as instance] (http://localhost:8080/packages/flutter/src/services/restoration.dart.lib.js:5825:35) at platform_channel.MethodChannel.new.setMethodCallHandler (http://localhost:8080/packages/flutter/src/services/restoration.dart.lib.js:1592:74) at VibrationWebPlugin.registerWith (http://localhost:8080/packages/vibration_web/vibration_web.dart.lib.js:47:15) at Object.registerPlugins (http://localhost:8080/packages/swoddy/generated_plugin_registrant.dart.lib.js:57:38) at http://localhost:8080/web_entrypoint.dart.lib.js:39:39 at Object._checkAndCall (http://localhost:8080/dart_sdk.js:5279:16) at Object.dcall (http://localhost:8080/dart_sdk.js:5284:17) at http://localhost:8080/dart_sdk.js:140287:18 at Generator.next () at runBody (http://localhost:8080/dart_sdk.js:40660:34) at Object._async [as async] (http://localhost:8080/dart_sdk.js:40691:7) at _engine.AppBootstrap.new. (http://localhost:8080/dart_sdk.js:140285:67) at Object._checkAndCall (http://localhost:8080/dart_sdk.js:5279:16) at Object.callMethod (http://localhost:8080/dart_sdk.js:5322:17) at Object.dsend (http://localhost:8080/dart_sdk.js:5325:17) at _engine.AppBootstrap.new.autoStart (http://localhost:8080/dart_sdk.js:140622:20) at autoStart.next () at http://localhost:8080/dart_sdk.js:40641:33 at _RootZone.runUnary (http://localhost:8080/dart_sdk.js:40511:59) at _FutureListener.thenAwait.handleValue (http://localhost:8080/dart_sdk.js:35438:29) at handleValueCallback (http://localhost:8080/dart_sdk.js:35999:49) at _Future._propagateToListeners (http://localhost:8080/dart_sdk.js:36037:17) at [_completeWithValue] (http://localhost:8080/dart_sdk.js:35872:23) at http://localhost:8080/dart_sdk.js:35077:46 at _RootZone.runUnary (http://localhost:8080/dart_sdk.js:40511:59) at handleValueCallback (http://localhost:8080/dart_sdk.js:35999:49) at _Future._propagateToListeners (http://localhost:8080/dart_sdk.js:36037:17) at [_completeWithValue] (http://localhost:8080/dart_sdk.js:35872:23) at async._AsyncCallbackEntry.new.callback (http://localhost:8080/dart_sdk.js:35906:35) at Object._microtaskLoop (http://localhost:8080/dart_sdk.js:40778:13) at _startMicrotaskLoop (http://localhost:8080/dart_sdk.js:40784:13) at http://localhost:8080/dart_sdk.js:36261:9

benjamindean commented 1 year ago

Have you tried following the suggestion? Adding WidgetsFlutterBinding.ensureInitialized(); in the main method.

imariman commented 1 year ago

Yes, I always have this line of code at the first row of the main method.

benjamindean commented 1 year ago

Ca you, please, provide some context like the code itself (if possible) and your Fultter dctor report. Meanwhile, you can still use the previous version. I'll try to fix it ASAP.

Shakle commented 1 year ago

Confirm, does not run

bytelyus commented 1 year ago

+1 ... Same situation... Did delete Vibration pluging and app worked again ...

'WidgetsFlutterBinding.ensureInitialized();' is the first line on my main() !!?!?!?....

... flutter doctor -v:

[✓] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-x64, locale es-ES) • Flutter version 3.0.5 at /Users/name/develop/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision f1875d570e (13 days ago), 2022-07-13 11:24:16 -0700 • Engine revision e85ea0e79c • Dart version 2.17.6 • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at /Users/name/Library/Android/sdk • Platform android-31, build-tools 29.0.2 • ANDROID_HOME = /Users/name/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.3.3) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin version 45.1.2 • Dart plugin version 193.7547

[✓] Connected device (4 available) • M2101K7BNY (mobile) • GYSKCMBYCALNIBLZ • android-arm64 • Android 11 (API 30) • iPhone (mobile) • b17910e7755fff4386a5acb1ff09fb23f9cba5b3 • ios • iOS 15.1 19B74 • macOS (desktop) • macos • darwin-x64 • macOS 12.4 21F79 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.134

[✓] HTTP Host Availability • All required HTTP hosts are available

• No issues found!

benjamindean commented 1 year ago

@bytelyus @Shakle @imariman Released a new version (1.7.5), please, update and verify if it works.

bytelyus commented 1 year ago

Great!!! .. Mine is working fine again :)

Thanks so much @benjamindean for such a good & fast response ...

Flutter 4 live!!