Sobes.tech
Junior — Middle

Can you explain the concept of external in Dart and how it is used?

sobes.tech AI

Answer from AI

In the Dart language, the keyword external is used to declare functions, methods, or variables whose implementation is outside the current Dart code. This allows linking Dart with native code (e.g., C/C++), platform APIs, or generated code.

For example, if you are writing a plugin for Flutter, you can declare a method as external, and its implementation will be on the platform side (Android/iOS).

Example:

external int nativeAdd(int a, int b);

Here, nativeAdd is declared but not implemented in Dart — the implementation will be provided externally.

Thus, external helps integrate Dart with external libraries and platform capabilities.

Can you explain the concept of external in Dart and… - sobes.tech