When you build a Flutter app, it’s not just about the code you write in Dart and the Flutter framework. There’s also a crucial piece called the platform embedders that enable your Flutter app to run on different operating systems like Android, iOS, and so on.
当你构建一个Flutter应用程序时,它不仅仅是关于你在Dart和Flutter框架中编写的代码。还有一个关键的部分叫做平台嵌入器,它可以让你的Flutter应用在不同的操作系统上运行,比如Android、iOS等等。
Think of the platform embedders as the bridge between your Flutter app and the underlying operating system. They handle the communication, integration, and execution of your Flutter code on the target platform.
把平台嵌入器看作是你的Flutter应用和底层操作系统之间的桥梁。他们在目标平台上处理您的Flutter代码的通信、集成和执行。
Each platform, such as Android and iOS, has its own specific platform embedder. These embedders are written in languages like Java and C++ for Android, Objective-C/Objective-C++ for iOS and macOS, and C++ for Windows and Linux. They provide the necessary entry point for your Flutter app and handle important tasks like rendering surfaces, accessibility, and input.
每个平台(如Android和iOS)都有自己特定的平台嵌入器。这些嵌入程序是用Java和c++编写的,适用于Android,适用于iOS和macOS的Objective-C/ objective - c++,适用于Windows和Linux的c++。它们为您的Flutter应用程序提供必要的入口点,并处理重要的任务,如渲染表面,可访问性和输入。
The platform embedder is responsible for coordinating with the underlying operating system and providing the necessary services and resources that your Flutter app needs to run smoothly. It acts as a mediator, translating Flutter’s crossplatform code into platform-specific instructions that the operating system understands.
平台嵌入器负责与底层操作系统协调,并提供您的Flutter应用程序顺利运行所需的必要服务和资源。它充当中介,将Flutter的跨平台代码翻译成操作系统能够理解的特定于平台的指令。
For example, when you interact with a button in your Flutter app, the platform embedder handles the touch events, communicates with the operating system to update the UI, and ensures that the button behaves as expected on the specific platform. It ensures that your Flutter app feels native and integrates seamlessly with the underlying system.
例如,当您在Flutter应用程序中与按钮交互时,平台嵌入器会处理触摸事件,与操作系统通信以更新UI,并确保按钮在特定平台上的行为符合预期。它确保您的Flutter应用程序感觉原生,并与底层系统无缝集成。
Flutter provides a set of built-in platform embedders for common target platforms like Android, iOS, macOS, and Windows. These embedders are well-maintained and optimized for performance. However, it’s worth noting that Flutter is designed to be extensible and customizable, so you can also create your own platform embedders if needed.
Flutter为常见的目标平台(如Android、iOS、macOS和Windows)提供了一组内置的平台嵌入器。这些嵌入器得到了良好的维护和性能优化。然而,值得注意的是,Flutter被设计为可扩展和可定制的,因此如果需要,您也可以创建自己的平台嵌入器。
The platform embedders play a vital role in making Flutter a truly multi-platform framework. They enable you to write your app’s UI and logic once in Flutter and deploy it to multiple platforms, ensuring a consistent user experience across different devices and operating systems.
平台嵌入器在使Flutter成为一个真正的多平台框架方面起着至关重要的作用。它们使您能够在Flutter中编写应用程序的UI和逻辑,并将其部署到多个平台,确保跨不同设备和操作系统的一致用户体验。