Flutter - How does it work behind the scenes?

2019-02-11 21:53发布

问题:

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.

回答1:

The Dart source code is compiled to native code using Dart's AoT compliation feature. It still needs the Dart VM to run though, but the code is compiled to native code ahead of time, because iOS doesn't allow dynamic compilation.

Flutter can also call out to Android and use Android features only available in Java. Flutter supports to build custom plugins that allow to call out to native platform code.



回答2:

Let me Explain with the help of this Diagram:

Flutter is built using Dart programming language. Flutter has 2 main components:

  1. Flutter Framework.
  2. Flutter SDK.

Flutter Framework uses Dart as programming language and Framework has a set of utility functions through which you can add UI Elements and Widgets in your Flutter App.

And Flutter SDK allows you to build and deploy and customize your Flutter Apps.

Flutter uses Dart

Because Dart is strongly typed Object Oriented programming language. And it has features of Ahead of time compilation and Just in Time Compilation.

Ahead of time compilation make Flutter SDK and Dart eligible to generate Native ARM Code which can be compiled on Android and iOS.

For more details you can watch this video: How Flutter Works and Why Flutter uses Dart



标签: dart flutter