this.settings = settings;
initStartTimestampMillis = SystemClock.uptimeMillis();
///配置 aotSharedLibraryName、flutterAssetsDir、
/// vmSnapshotData、isolateSnapshotData
///等参数
initConfig(appContext);
///初始化VsyncWaiter,并设置回调
/// 当vsync信号到来时,就调用我们设置的回调,最终会触发页面的刷新
VsyncWaiter.getInstance((WindowManager) appContext.getSystemService(Context.WINDOW_SERVICE))
.init();
// 子线程
///这里主要是抽取资源文件,
///加载 flutter(libflutter.so)代码
Callable initTask =
new Callable() {
@Override
public InitResult call() {
ResourceExtractor resourceExtractor = initResources(appContext);
System.loadLibrary(“flutter”);
// Prefetch the default font manager as soon as possible on a background thread.
// It helps to reduce time cost of engine setup that blocks the platform thread.
Executors.newSingleThreadExecutor()
.execute(
new Runnable() {
@Override
public void run() {
FlutterJNI.nativePrefetchDefaultFontManager();
}
});
if (resourceExtractor != null) {
resourceExtractor.waitForCompletion();
}
return new InitResult(
PathUtils.getFilesDir(appContext),
PathUtils.getCacheDirectory(appContext),
PathUtils.getDataDirectory(appContext));
}
};
initResultFuture = Executors.newSingleThreadExecutor().submit(initTask);
}
至此FlutterApplication 的相关流程就走完了。
另外ÿ