Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin doesn't work with mainactivity.kt #2

Open
flutterboi opened this issue Aug 19, 2020 · 4 comments
Open

Plugin doesn't work with mainactivity.kt #2

flutterboi opened this issue Aug 19, 2020 · 4 comments

Comments

@flutterboi
Copy link

it appears that the plugin does not work when the flutter app uses a kotlin based main activity.
I followed the example and modified the java code to meet the Kotlin syntax but was met with an error saying that it expected a function in java form, not kotlin.

@imse-ty
Copy link

imse-ty commented Aug 26, 2020

Ditto, any suggestions?

@hectorAguero
Copy link

So, I'm try to use this package but now it's to difficult to find the key to register a new package, because they doesn't show in the generatedpluginregistrant file

by the way, probably this it's the kotlin file

package change.this.withyourprojectname

import androidx.annotation.NonNull
import androidx.arch.core.util.Function
import dev.thinkng.flt_worker.FltWorkerPlugin.*
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.GeneratedPluginRegistrant


class MainActivity: FlutterActivity() {
    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine)
        FltWorkerPlugin.registerPluginsForWorkers = Function { registry: PluginRegistry ->
            io.flutter.plugins.pathprovider.PathProviderPlugin.registerWith(
                    registry.registrarFor("io.flutter.plugins.pathprovider.PathProviderPlugin"))
            //// If you need to add another package
           //// io.flutter.plugins.pathprovider.PathProviderPlugin.registerWith(
           ////         registry.registrarFor("io.flutter.plugins.pathprovider.PathProviderPlugin"))

            null
        }
    }
}

@jbpoulsen
Copy link

Has anyone managed to make this work with kotlin?

@bettysteger
Copy link

@hectorAguero have you got a solution?

Can i just register all plugins for the background task?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants