What does external mean in Dart?

萝らか妹 提交于 2021-01-17 17:40:50

问题


What does external mean in Dart? For example: external DateTime._now();

I'm new to Dart, I can't find documentation for external, so can you give an example to help explain?


回答1:


9.4 External Functions
An external function is a function whose body is provided separately from its
declaration. An external function may be a top-level function (17), a method

The body of the function is defined somewhere else.
As far as I know this is used to fix different implementations for Dart VM in the browser and Dart VM on the Server.




回答2:


When we make an external function inside a class like toString()

external String toString();

means this function is abstract and the child of the parent class will add the function body, that's because in Dart we only can make an abstract class.

Summary:

external function = abstract function in not abstract classes



来源:https://stackoverflow.com/questions/24929659/what-does-external-mean-in-dart

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!