Code Monkey home page Code Monkey logo

Comments (3)

JCKodel avatar JCKodel commented on May 20, 2024

Note: This happens only on VSCode.
Android Studio starts the app (but my task is never triggered).

Continuing after the first error:

Exception has occurred.
PlatformException (PlatformException(1, You have not properly initialized the Flutter WorkManager Package. You should ensure you have called the 'initialize' function first! Example: 

`Workmanager.initialize(
  callbackDispatcher,
 )`

The `callbackDispatcher` is a top level function. See example in repository., null))

BTW, I've inserted this on my App.kt file: Log.d("WorkmanagerPlugin", "WorkmanagerPlugin is initializing") and this log appears on catlog when the app is initialized (before Flutter first frame is rendered and the bug manifests itself).

After running a couple of times (and moving this initialization first thing in my flutter main), the first error doesn't occur anymore, but the second remains:

image

I also have to write this: WidgetsFlutterBinding.ensureInitialized();, otherwise, my app says:

Exception has occurred.
FlutterError (ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.
If you're running an application and need to access the binary messenger before `runApp()` has been called (for example, during plugin initialization), then you need to explicitly call the `WidgetsFlutterBinding.ensureInitialized()` first.
If you're running a test, you can call the `TestWidgetsFlutterBinding.ensureInitialized()` as the first line in your test's `main()` method to initialize the binding.)

from flutter_workmanager.

timrijckaert avatar timrijckaert commented on May 20, 2024

Is your callbackDispatcher a top level function?
Can you provide me with a sample that demonstrates this behaviour?

from flutter_workmanager.

JCKodel avatar JCKodel commented on May 20, 2024

That was the problem. Moving the function to public and outside the class made it work.

from flutter_workmanager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.