且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将Dart/Flutter编译为Android?

更新时间:2023-11-10 17:00:16

Dart被编译为本机代码(ARM,Intel等)可执行文件,并与某些本机平台代码(Java,Kotlin,Objective-C/Swift)与本机平台进行交互.

Dart is compiled to native machine code (ARM, Intel, ...) executable and bundled with some native platform code (Java, Kotlin, Objective-C/Swift) to interact with the native platform.

另请参见

Flutter如何在Android上运行我的代码?引擎的C和C ++代码

是使用Android的NDK编译的.Dart代码(SDK和您的)被提前(AOT)编译到本地的ARM库中.该库包含在运行程序" Android项目中,整个库东西内置在APK中.启动后,该应用会加载Flutter图书馆.任何呈现,输入或事件处理等都是委托给已编译的Flutter和应用程序代码.这类似于许多游戏引擎的工作方式.

How does Flutter run my code on Android? The engine’s C and C++ code

are compiled with Android’s NDK. The Dart code (both the SDK’s and yours) are ahead-of-time (AOT) compiled into a native, ARM library. That library is included in a "runner" Android project, and the whole thing is built into an APK. When launched, the app loads the Flutter library. Any rendering, input or event handling, and so on, are delegated to the compiled Flutter and app code. This is similar to the way many game engines work.

调试模式构建使用虚拟机(VM)运行Dart代码(因此他们显示的调试"横幅提醒人们较慢)以启用有状态的热重装.

Debug mode builds use a virtual machine (VM) to run Dart code (hence the "debug" banner they show to remind people that they’re slightly slower) in order to enable stateful hot reload.

与LLVM一起编译.Dart代码(包括SDK和您的)都是提前(AOT)编译到本地ARM库中.那个图书馆包含在一个运行程序" iOS项目中,并且整个过程都已构建.ipa.启动后,该应用程序将加载Flutter库.任何呈现,输入或事件处理等,都委托给编译Flutter和应用程序代码.这类似于许多游戏的方式引擎正常工作.

compiled with LLVM. The Dart code (both the SDK’s and yours) are ahead-of-time (AOT) compiled into a native, ARM library. That library is included in a "runner" iOS project, and the whole thing is built into an .ipa. When launched, the app loads the Flutter library. Any rendering, input or event handling, and so on, are delegated to the compiled Flutter and app code. This is similar to the way many game engines work.

调试模式版本使用虚拟机(VM)运行Dart代码(因此他们显示的调试"标语提醒人们较慢)以启用有状态的热重装.

Debug mode builds use a virtual machine (VM) to run Dart code (hence the "debug" banner they show to remind people that they’re slightly slower) in order to enable stateful hot reload.

https://flutter.io/docs/resources/faq#how-does-flutter-run-my-code-on-android

另请参见 https://proandroiddev.com/flutters-compilation-patterns-24e139d14177