Skip to content
Discussion options

You must be logged in to vote

简短回答:你的排查是对的。overlayMain 必须在 main.dart 里,因为插件是按函数名在应用根库里查找入口点的。下面给出两种封装路线:本地模板目录(最简单、版本安全)或 fork 模板仓库,另外还有一个最小改动的变体。

Your diagnosis is correct, and here is the mechanism behind it. The overlay runs in a second FlutterEngine, and the plugin creates that engine with an entrypoint built like this (in onAttachedToActivity, source, with the same construction repeated as a fallback in OverlayService):

DartExecutor.DartEntrypoint(
    FlutterInjector.instance().flutterLoader().findAppBundlePath(),
    "overlayMain")

An entrypoint given only by function name is resolved in the root library of the app bundle, which is lib/main.dart. A @pragma("vm:entry-point") function inside an extension package …

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@yst-one
Comment options

@RenSolvyn
Comment options

@RenSolvyn
Comment options

@yst-one
Comment options

@RenSolvyn
Comment options

Answer selected by yst-one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
help wanted Extra attention is needed
2 participants