简体   繁体   English

每个 Flutter 应用都包含 Flutter 引擎吗?

[英]Does every flutter app contain Flutter engine?

I am trying to digest the following information from Flutter site.我正在尝试从 Flutter 站点中消化以下信息。

How does Flutter run my code on Android? Flutter 如何在 Android 上运行我的代码?

The engine's C and C++ code are compiled with Android's NDK.引擎的 C 和 C++ 代码使用 Android 的 NDK 编译。 The Dart code (both the SDK's and yours) are ahead-of-time (AOT) compiled into native, ARM, and x86 libraries. Dart 代码(SDK 的和您的)是提前 (AOT) 编译到本机、ARM 和 x86 库中的。 Those libraries are included in a “runner” Android project, and the whole thing is built into an APK.这些库包含在一个“runner”Android 项目中,整个项目都内置在一个 APK 中。 When launched, the app loads the Flutter library.启动时,应用程序会加载 Flutter 库。 Any rendering, input, or event handling, and so on, is delegated to the compiled Flutter and app code.任何渲染、输入或事件处理等都委托给已编译的 Flutter 和应用程序代码。 This is similar to the way many game engines work.这类似于许多游戏引擎的工作方式。

Is each Flutter app (more precisely each Android app that is created with Flutter) published with Flutter engine attached?每个 Flutter 应用程序(更准确地说是每个使用 Flutter 创建的 Android 应用程序)是否都附带 Flutter 引擎?

Yes, it is included in every app.是的,它包含在每个应用程序中。 There is no code sharing between apps on Android/iOS. Android/iOS 上的应用程序之间没有代码共享。 Also each app could have a different version of the engine (depending on when it was compiled)此外,每个应用程序都可以有不同版本的引擎(取决于编译时间)

Note that the with the upcoming Flutter 1.0, the overhead (on Android) is less than 5M, which is not bad.请注意,随着即将推出的 Flutter 1.0,开销(在 Android 上)小于 5M,这还不错。 I believe the overhead is similar on iOS.我相信 iOS 上的开销是相似的。

libflutter.so 在我的模拟器上是 27.1MB,用于完整/生产应用程序和 hello world 应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM