Flutter - 它在幕后是如何工作的? [英] Flutter - How does it work behind the scenes?
问题描述
显然,flutter 是一种使用一个代码库在 iOS
和 Android
上运行应用程序的框架.但它是如何做到的?它会编译为本机代码,还是有中级语言或 VM 参与该过程?我尝试阅读 Github 上的一些源代码,但找不到任何内容.
Obviously, flutter is a framework for running apps on iOS
and Android
using one codebase. But how does it manage to do so? Will it compile to native code, or is there a mid level language or a VM involved in the process? I tried reading some of the source code on Github, but I couldn't find anything.
推荐答案
Dart 源代码使用 Dart 的 AoT 编译功能编译为本机代码.它仍然需要部分 Dart VM(一些运行时组件,如垃圾收集)才能运行,但代码会提前编译为本机代码,因为 iOS 不允许动态编译.
The Dart source code is compiled to native code using Dart's AoT compilation feature. It still needs parts of the the Dart VM (some runtime components like garbage collection) to run though, but the code is compiled to native code ahead of time, because iOS doesn't allow dynamic compilation.
Flutter 还可以调用 Android 并使用仅在 Java 中可用的 Android 功能(与 iOS 相同).Flutter 支持构建自定义插件(除了很多提供的插件)来调用原生平台代码.
Flutter can also call out to Android and use Android features only available in Java (same with iOS). Flutter supports to build custom plugins (in addition to a lot of provided ones) to call out to native platform code.
这篇关于Flutter - 它在幕后是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!