flutter / samples

A collection of Flutter examples and demos

Home Page:https://flutter.github.io/samples/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple flutter add-to-app sample module should include a plugin to demonstrate GeneratedPluginRegistrant

jmagman opened this issue · comments

Received a customer support of a MissingPluginException(No implementation found for method) error when prototyping FlutterEngineGroup in a host app, based off the add-to-app sample module sample. The customer was missing GeneratedPluginRegistrant.register in their host app.

To demonstrate how to register plugins with makeEngine, add a plugin to the module, then in the host app change

let newEngine = appDelegate.engines.makeEngine(withEntrypoint: entryPoint, libraryURI: nil)
super.init(engine: newEngine, nibName: nil, bundle: nil)

to

    let newEngine = appDelegate.engines.makeEngine(withEntrypoint: entryPoint, libraryURI: nil)
    GeneratedPluginRegistrant.register(with: newEngine)
    super.init(engine: newEngine, nibName: nil, bundle: nil)

@gaaclarke does that registration point look correct?

@jmagman That may work. I'd have to test it. We've gotten some other complaints about not having time to do initialization work when using FlutterEngineGroup.makeEngine. We may have to tweak the API to allow things
like GeneratedPluginRegistrat. The semantics for makeEngine is that it makes and runs an engine where typically those are 2 different steps with regular engines.

That may work. I'd have to test it.

It worked when I tested it, just wanted your sanity check.

The current add-to-app iOS instructions say to run the engine before GeneratedPluginRegistrant.register, so if makeEngine also runs it then this seems equivalent (though maybe the docs aren't correct and registration should happen before run?)

    flutterEngine.run();
    // Used to connect plugins (only if you have plugins with iOS platform code).
    GeneratedPluginRegistrant.register(with: self.flutterEngine);

@jmagman Okay, cool that sounds good to me then. Thanks for looking into it.

Just triaging here: is this something one of y'all would like to knock out?

Just triaging here: is this something one of y'all would like to knock out?

I can take it.