Dart Native Interop

repository·main·Indexed 43 days ago

https://github.com/dart-lang/native

Foundational ecosystem for Dart native interop, featuring FFI utilities, binding generators like ffigen and jnigen, and tools for managing native asset building and bundling via build and link hooks. Includes package:code_assets for managing executable code assets (C, C++, Rust, Go) and guidance on using the dart:ffi library for C interop.

Tokens
66.3K
Snippets
200
Records
334
Agent score
55%

What's inside Dart Native

  1. Overview of package:ffigen

    main

    package:ffigen is a tool designed to simplify generating dart:ffi bindings from C and Objective-C header files. It uses a Dart script configuration via an FfiGenerator object to define how bindings are produced.

    Requirements:

    • LLVM (version 18 or higher) must be installed on your system.
  2. Overview of the stb_image demonstration project

    main

    This project serves as a minimal, cross-platform demonstration of integrating Dart with native C libraries. It showcases three key technologies:

    1. Dart Build Hooks: Used to automate the compilation of native code.
    2. Code Assets: Used to manage and include external files.
    3. dart:ffi: Used to call C functions from Dart.

    The specific implementation uses the stbi_info function from the stb_image.h library to retrieve an image's dimensions and color channels without loading the full file into memory.

  3. Overview of Dart Native Assets and FFI packages

    main
    The dart-lang/native repository contains a collection of Dart packages designed to facilitate Foreign Function Interface (FFI) and the building and bundling of native assets. These tools allow Dart and Flutter developers to interoperate with native code (C, C++, Objective-C, Swift, Java, Kotlin, etc.) and manage native build processes.
  4. Overview of JNI Flutter

    main
    JNI Flutter is a support library designed to allow Dart code to access Flutter-specific Android APIs via the Java Native Interface (JNI). It is a specialized spin-off of the package:jni library, specifically containing the APIs required to interact with the Flutter Android framework.
  5. Overview of native_toolchain_c

    main

    The native_toolchain_c package is a library designed to invoke the native C compiler installed on the host machine.

    Warning: This package is currently experimental and published under the labs.dart.dev publisher. Users should expect a high rate of API changes and potential discontinuation. It is intended to solicit feedback to help evolve the package.