[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-flutter-dart-setup-ffi-assets":3,"mdc--om07jf-key":32,"related-repo-flutter-dart-setup-ffi-assets":3367,"related-org-flutter-dart-setup-ffi-assets":3445},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":22,"repoUrl":23,"updatedAt":24,"license":25,"forks":26,"topics":27,"repo":28,"sourceUrl":30,"mdContent":31},"dart-setup-ffi-assets","package C\u002FC++ assets for Dart","Guides agents in compiling and packaging C\u002FC++ source code into dynamic or static libraries (Code Assets) using Dart's Native Assets hook system (via hook\u002Fbuild.dart and hook\u002Flink.dart utilizing package:hooks and package:native_toolchain_c). Use when a user asks to: 'setup native assets', 'compile C\u002FC++ source code', 'bundle dynamic libraries', 'build native C code', 'link native assets', 'implement build.dart or link.dart hooks', or 'integrate C\u002FC++ interop in Dart\u002FFlutter'. Helps agents avoid manual toolchain orchestration and configures secure hash-validated binary downloads or advanced linker tree-shaking with package:record_use mapping.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},"flutter","Flutter (Google)","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Fflutter.png",[12,16,19],{"name":13,"slug":14,"type":15},"Deployment","deployment","tag",{"name":17,"slug":18,"type":15},"Engineering","engineering",{"name":20,"slug":21,"type":15},"Dart","dart",2664,"https:\u002F\u002Fgithub.com\u002Fflutter\u002Fagent-plugins","2026-07-15T05:22:20.138636",null,155,[],{"repoUrl":23,"stars":22,"forks":26,"topics":29,"description":25},[],"https:\u002F\u002Fgithub.com\u002Fflutter\u002Fagent-plugins\u002Ftree\u002FHEAD\u002Fskills\u002Fdart-setup-ffi-assets","---\nname: dart-setup-ffi-assets\ndescription: \"Guides agents in compiling and packaging C\u002FC++ source code into dynamic or static libraries (Code Assets) using Dart's Native Assets hook system (via hook\u002Fbuild.dart and hook\u002Flink.dart utilizing package:hooks and package:native_toolchain_c). Use when a user asks to: 'setup native assets', 'compile C\u002FC++ source code', 'bundle dynamic libraries', 'build native C code', 'link native assets', 'implement build.dart or link.dart hooks', or 'integrate C\u002FC++ interop in Dart\u002FFlutter'. Helps agents avoid manual toolchain orchestration and configures secure hash-validated binary downloads or advanced linker tree-shaking with package:record_use mapping.\"\nmetadata:\n  model: models\u002Fgemini-3.1-pro-preview\n  last_modified: Fri, 29 May 2026 09:10:00 GMT\n---\n# Compiling C Code into Code Assets with Native Assets Hooks\n\nIntegrate and automate the compilation and packaging of native C\u002FC++ source code into **Code Assets** under Dart's overarching **Native Assets** feature using build and link hooks.\n\n## Contents\n- [Introduction](#introduction)\n- [Constraints](#constraints)\n- [Native Interop Packages](#native-interop-packages)\n- [Step-by-Step Workflow](#step-by-step-workflow)\n- [Choosing an Integration Approach](#choosing-an-integration-approach)\n- [Method 1: Local Compilation with Linker Tree-Shaking (Recommended)](#method-1-local-compilation-with-linker-tree-shaking-recommended)\n  - [Prerequisite Host Compiler Toolchains](#prerequisite-host-compiler-toolchains)\n  - [C Source and Bindings Setup](#c-source-and-bindings-setup)\n  - [Defining the C Library Build Spec](#defining-the-c-library-build-spec)\n  - [Implementing hook\u002Fbuild.dart](#implementing-hookbuilddart)\n  - [Implementing hook\u002Flink.dart](#implementing-hooklinkdart)\n- [Method 2: Downloading Precompiled Dynamic Libraries](#method-2-downloading-precompiled-dynamic-libraries)\n  - [Why Download Precompiled Binaries?](#why-download-precompiled-binaries)\n  - [Implementing Precompiled Dynamic Downloads](#implementing-precompiled-dynamic-downloads)\n- [Verification Checklist](#verification-checklist)\n  - [1. Local Execution Sandbox](#1-local-execution-sandbox)\n  - [2. Verify Target Outputs](#2-verify-target-outputs)\n  - [3. Verify Tree-Shaking Stripping](#3-verify-tree-shaking-stripping)\n  - [4. Verify Offline Compliance (User Defines)](#4-verify-offline-compliance-user-defines)\n\n---\n\n## Introduction\n\nUnder Dart's **Native Assets** feature, packages can package native code (like C\u002FC++ libraries) as **Code Assets** and bundle them automatically during standard development cycles (e.g., `dart run`, `dart test`, `dart build`, and `flutter run`). The packaging of **Code Assets** is driven by two programmatic hook scripts placed inside a package's `hook\u002F` folder:\n\n1.  `hook\u002Fbuild.dart`: Compiles local C sources to machine code or bundles prebuilt native binaries as code assets for a specific host\u002Ftarget architecture.\n2.  `hook\u002Flink.dart`: Links built code assets, applying advanced tree-shaking optimizations to strip unused native symbols and compress the runtime binary size.\n\n---\n\n## Constraints\n\n> [!IMPORTANT]\n> Keep all file resolving platform-independent. Never hardcode absolute target paths, shell scripts, or system command variables. Always use `Platform.script.resolve()` or `Uri`-based resolution to ensure scripts are fully portable.\n\n*   **Hook Locations**: Compiling and packaging hooks must reside strictly inside the `hook\u002F` directory at the package's root:\n    *   `hook\u002Fbuild.dart` (Build execution phase)\n    *   `hook\u002Flink.dart` (Optional packaging\u002Flinking\u002Ftree-shaking phase)\n*   **Compile Toolchain Standard**: Use the programmatic APIs from `package:native_toolchain_c` (e.g. `CBuilder` and `CLibrary`) to run compile toolchains. Never invoke raw `gcc`, `clang`, or `msvc` via shell commands.\n*   **Preamble & License Headers**: Every handcrafted and generated source file (including bindings, helpers, and hooks) must strictly contain the target package's copyright and licensing header.\n*   **Tree Shaking Mapping**: If utilizing compiler tree-shaking, you must map the target Dart method names (e.g. `Method.name`) back to their raw native C symbol names using a record use mapping generated by FFIgen. The mapping file must reside under `lib\u002Fsrc\u002Fthird_party\u002F` and strictly use the `.g.dart` extension (e.g., `sqlite3.record_use_mapping.g.dart`).\n*   **Integrity Safeguards for Precompiled Libraries**: If adopting the dynamic download pattern:\n    *   **Cryptographic Verification**: Downloaded prebuilt binaries must be checked against preconfigured lookup tables containing MD5 or SHA-256 hashes to guarantee binary integrity and prevent tampering.\n    *   **Graceful Recovery**: Support offline developers by providing fallbacks (such as local compiler execution via flags like `local_build`).\n\n---\n\n## Native Interop Packages\n\nProgrammatic build and link hooks for **Code Assets** leverage three specialized native interop packages:\n\n| Dependency | Purpose | Key API Abstractions |\n| :--- | :--- | :--- |\n| **`package:hooks`** | Main orchestrator defining execution bounds. | `build(args, callback)`, `link(args, callback)` |\n| **`package:native_toolchain_c`** | Detects local compilers (MSVC, Xcode\u002FClang, GCC) and executes build toolchains. | `CLibrary`, `CBuilder`, `LinkerOptions.treeshake` |\n| **`package:code_assets`** | Models code metadata records passed to dynamic loaders. | `CodeAsset`, `DynamicLoadingBundled` |\n\n---\n\n## Step-by-Step Workflow\n\n### Step 1: Add Dependencies\nAdd Code Assets hook and toolchain dependencies to your package. You must fetch these dependencies directly from **pub.dev**.\n\nYou can add it automatically using the CLI:\n```bash\ndart pub add code_assets hooks native_toolchain_c record_use dev:ffigen\n```\n\nOr manually declare them in your target package's `pubspec.yaml`:\n```yaml\ndependencies:\n  code_assets: ^1.0.0\n  hooks: ^0.1.0\n  native_toolchain_c: ^0.1.0\n  record_use: ^0.6.0\n\ndev_dependencies:\n  ffigen: ^20.1.1\n```\n\n### Step 2: Define C Specifications\nDefine your target C library compilation metadata inside `lib\u002Fsrc\u002Fc_library.dart`. This lets both the build and link hooks share a single source of truth for assets, names, and sources.\n\n### Step 3: Implement Build and Link Hook Scripts\nWrite the compilation orchestration script inside `hook\u002Fbuild.dart` and the dead-code elimination logic inside `hook\u002Flink.dart`.\n\n### Step 4: Run the Hook Cycle\nRunning standard test suites dynamically launches the build and link hook lifecycle in the background:\n```bash\ndart test\n```\n\n---\n\n## Choosing an Integration Approach\n\nThere are two primary methods for integrating and delivering C\u002FC++ native assets in Dart. Select the one that matches your project requirements:\n\n| Aspect | Method 1: Local Compilation & Tree-Shaking | Method 2: Precompiled Downloads |\n| :--- | :--- | :--- |\n| **Primary Use Case** | When C\u002FC++ source code is included directly in the package and you want maximum size optimization. | When compiling locally is slow\u002Fcomplex, or when avoiding developer host toolchain requirements. |\n| **Host Toolchain Requirements** | Requires pre-installed platform C compiler (Xcode tools, MSVC, GCC). | Zero compiler setup required on developer\u002Fuser machines. |\n| **Binary Optimization** | Premium. Unused symbols are completely tree-shaken, decreasing library size. | Standard. Standard compiled binaries are shipped as-is. |\n| **Offline Setup** | Fully compliant. Works completely offline. | Requires network access to download libraries, with offline fallback. |\n\n---\n\n## Method 1: Local Compilation with Linker Tree-Shaking (Recommended)\n\nIn this approach, the build hook invokes local toolchains (GCC, Clang, MSVC) to compile source files directly. The link hook subsequently filters output symbols utilizing compiler options, retaining only target methods invoked in user code. This represents the standard, robust SQLite pattern under `pkgs\u002Fcode_assets\u002Fexample\u002Fsqlite`.\n\n### Prerequisite Host Compiler Toolchains\n\nSince `package:native_toolchain_c` delegates actual dynamic compilation to the host operating system's default toolchain, the development machine **must** have one of the following compiler packages pre-installed:\n\n*   **macOS**: Xcode Command Line Tools. Install via:\n    ```bash\n    xcode-select --install\n    ```\n*   **Linux**: GCC or Clang. Install via:\n    ```bash\n    sudo apt install build-essential\n    ```\n*   **Windows**: MSVC (Microsoft Visual C++). Install the **Visual Studio Installer** and select the **Desktop development with C++** workload.\n\n*Note: If no compatible toolchain is discovered on the host path, the build hook script will throw a compilation execution exception. Ensure to specify compiler constraints or adopt Method 2 if toolchains cannot be guaranteed.*\n\n### C Source and Bindings Setup\n\nAssume a C source defining simple math functions at `third_party\u002Fsqlite\u002Fsqlite3.c` with its entry point header at `third_party\u002Fsqlite\u002Fsqlite3.h`:\n\n```c\n#ifndef SQLITE3_H_\n#define SQLITE3_H_\n\nconst char *sqlite3_libversion(void);\n\n#endif \u002F\u002F SQLITE3_H_\n```\n\nWe utilize a programmatic FFIgen script (`tool\u002Fffigen.dart`) to create FFI bindings in `lib\u002Fsrc\u002Fthird_party\u002Fsqlite3.g.dart`, enabling recorded usage tracking and producing the lookup metadata map in `lib\u002Fsrc\u002Fthird_party\u002Fsqlite3.record_use_mapping.g.dart`:\n\n```dart\n\u002F\u002F AUTO-GENERATED FILE - DO NOT MODIFY.\n\u002F\u002F Generated via ffigen.\n\nconst recordUseMapping = {\n  'sqlite3_libversion': 'sqlite3_libversion',\n};\n```\n\n### Defining the C Library Build Spec\n\nDefine the centralized library specification in `lib\u002Fsrc\u002Fc_library.dart`:\n\n```dart\nimport 'package:native_toolchain_c\u002Fnative_toolchain_c.dart';\n\n\u002F\u002F\u002F The C build specification for the sqlite library.\nfinal cLibrary = CLibrary(\n  name: 'sqlite3',\n  assetName: 'src\u002Fthird_party\u002Fsqlite3.g.dart',\n  sources: ['third_party\u002Fsqlite\u002Fsqlite3.c'],\n);\n```\n\n### Implementing `hook\u002Fbuild.dart`\n\nImplement `hook\u002Fbuild.dart` using `CLibrary.build`. This builds the library to a dynamic library (e.g. `.so`, `.dylib`, or `.dll`) inside the hook's target directory:\n\n```dart\nimport 'package:code_assets\u002Fcode_assets.dart';\nimport 'package:hooks\u002Fhooks.dart';\nimport 'package:sqlite\u002Fsrc\u002Fc_library.dart';\n\nvoid main(List\u003CString> args) async {\n  await build(args, (input, output) async {\n    if (input.config.buildCodeAssets) {\n      await cLibrary.build(\n        input: input,\n        output: output,\n        defines: {\n          if (input.config.code.targetOS == OS.windows)\n            \u002F\u002F Ensure C functions are explicitly exported in the Windows DLL\n            'SQLITE_API': '__declspec(dllexport)',\n        },\n      );\n    }\n  });\n}\n```\n\n### Implementing `hook\u002Flink.dart`\n\nImplement the link optimization phase in `hook\u002Flink.dart`. This utilizes compiler tree-shaking options (`LinkerOptions.treeshake`) to compile a minimized, dead-code-eliminated binary based on symbol usage records:\n\n```dart\nimport 'package:hooks\u002Fhooks.dart';\nimport 'package:native_toolchain_c\u002Fnative_toolchain_c.dart';\nimport 'package:record_use\u002Frecord_use.dart';\nimport 'package:sqlite\u002Fsrc\u002Fc_library.dart';\nimport 'package:sqlite\u002Fsrc\u002Fthird_party\u002Fsqlite3.record_use_mapping.g.dart';\n\nvoid main(List\u003CString> arguments) async {\n  await link(arguments, (input, output) async {\n    await cLibrary.link(\n      input: input,\n      output: output,\n      linkerOptions: LinkerOptions.treeshake(\n        \u002F\u002F Map Dart Method references back to raw C symbol names\n        symbolsToKeep: input.recordedUses?.calls.keys.cast\u003CMethod>().map(\n          (e) => recordUseMapping[e.name]!,\n        ),\n      ),\n    );\n  });\n}\n```\n\n---\n\n## Method 2: Downloading Precompiled Dynamic Libraries\n\nAn alternative approach compiles binaries beforehand on a central build machine, archives them, and downloads the target binary during the build hook execution. This matches the paradigm demonstrated in the `download_asset` hook package.\n\n### Why Download Precompiled Binaries?\n\n*   **Host Constraints**: Compiling large C\u002FC++ libraries locally requires a complete compiler setup (GCC, Xcode\u002FSDKs, Visual Studio) that the end-developer's host machine may not possess.\n*   **Compile Speed**: Precompiled downloads execute in milliseconds compared to potentially long multi-minute compilation processes.\n*   **Platform Bridging**: Allows cross-compiling constraints to be avoided if host architectures are limited.\n\n---\n\n### Implementing Precompiled Dynamic Downloads\n\nWe configure our build hook to detect local compiler flags (e.g. `local_build`). If not specified, the hook utilizes `HttpClient` to pull down platform-specific libraries, calculates the MD5 hash to confirm download safety against a configured hashes lookup table, and registers the binary file as a `CodeAsset`:\n\n#### 1. Defining Target Hashes (`lib\u002Fsrc\u002Fhook_helpers\u002Fhashes.dart`)\nDefine target MD5 hash checks per platform file in your package sources:\n\n```dart\nconst assetHashes = {\n  'libnative_add_macos_arm64.dylib': '4a88f50438a98402db2dbd47b59eb412',\n  'libnative_add_linux_x64.so': '9f5e15043aa98402dcdbbd47b59ea520',\n  'native_add_windows_x64.dll': 'a881e5043ba98402acdebd47b59fa321',\n};\n```\n\n#### 2. Hook Downloader Helper (`lib\u002Fsrc\u002Fhook_helpers\u002Fdownload.dart`)\nImplement the downloading and integrity check logic using dynamic target filename matching:\n\n```dart\nimport 'dart:io';\nimport 'package:code_assets\u002Fcode_assets.dart';\nimport 'package:crypto\u002Fcrypto.dart';\n\nconst version = '1.0.0';\n\nUri downloadUri(String target) => Uri.parse(\n  'https:\u002F\u002Fgithub.com\u002Fmy-org\u002Fmy-native-repo\u002Freleases\u002Fdownload\u002F$version\u002F$target',\n);\n\nFuture\u003CFile> downloadAsset(\n  OS targetOS,\n  Architecture targetArchitecture,\n  Directory outputDir,\n) async {\n  final fileName = targetOS.dylibFileName('native_add_${targetOS.name}_${targetArchitecture.name}');\n  final uri = downloadUri(fileName);\n  \n  final client = HttpClient()..findProxy = HttpClient.findProxyFromEnvironment;\n  final request = await client.getUrl(uri);\n  final response = await request.close();\n  \n  if (response.statusCode != 200) {\n    throw ArgumentError('Download target $uri failed: Code ${response.statusCode}');\n  }\n  \n  final targetFile = File.fromUri(outputDir.uri.resolve(fileName));\n  await targetFile.create(recursive: true);\n  await response.pipe(targetFile.openWrite());\n  \n  return targetFile;\n}\n\nFuture\u003CString> hashAsset(File file) async {\n  return md5.convert(await file.readAsBytes()).toString();\n}\n```\n\n#### 3. Implementing `hook\u002Fbuild.dart`\n\nWrite the final download build hook incorporating local compilation fallback:\n\n```dart\nimport 'dart:io';\nimport 'package:code_assets\u002Fcode_assets.dart';\nimport 'package:hooks\u002Fhooks.dart';\nimport 'package:my_download_package\u002Fsrc\u002Fhook_helpers\u002Fhashes.dart';\nimport 'package:my_download_package\u002Fsrc\u002Fhook_helpers\u002Fdownload.dart';\nimport 'package:native_toolchain_c\u002Fnative_toolchain_c.dart';\n\nvoid main(List\u003CString> args) async {\n  await build(args, (input, output) async {\n    final localBuild = input.userDefines['local_build'] as bool? ?? false;\n\n    if (localBuild) {\n      final name = 'native_add_${input.config.code.targetOS.name}_${input.config.code.targetArchitecture.name}';\n      final builder = CBuilder.library(\n        name: name,\n        assetName: 'native_add.dart',\n        sources: ['src\u002Fnative_add.c'],\n      );\n      await builder.run(input: input, output: output);\n    } else {\n      final targetOS = input.config.code.targetOS;\n      final targetArch = input.config.code.targetArchitecture;\n      final outputDir = Directory.fromUri(input.outputDirectory);\n\n      final file = await downloadAsset(targetOS, targetArch, outputDir);\n\n      final fileHash = await hashAsset(file);\n      final expectedFileName = targetOS.dylibFileName('native_add_${targetOS.name}_${targetArch.name}');\n      final expectedHash = assetHashes[expectedFileName];\n\n      if (fileHash != expectedHash) {\n        throw Exception(\n          'Security Mismatch: File $expectedFileName hash verification failed! '\n          'Found hash: $fileHash, expected: $expectedHash.'\n        );\n      }\n\n      output.assets.code.add(\n        CodeAsset(\n          package: input.packageName,\n          name: 'native_add.dart',\n          linkMode: DynamicLoadingBundled(),\n          file: file.uri,\n        ),\n      );\n    }\n  });\n}\n```\n\n---\n\n## Verification Checklist\n\nBefore declaring a build or link hook implementation complete, always perform the following checks:\n\n### 1. Local Execution Sandbox\nRun unit tests and confirm the native assets compile\u002Flink process completes with no runtime or build tool exceptions:\n```bash\ndart test\n```\n\n### 2. Verify Target Outputs\nNavigate to your package target directory and verify that dynamic binary assets are created for the host system:\n*   **macOS**: Verify `.dart_tool\u002Fresources\u002F` or target directories contain `.dylib` files.\n*   **Linux**: Verify `.dart_tool\u002Fresources\u002F` or target directories contain `.so` files.\n*   **Windows**: Verify `.dart_tool\u002Fresources\u002F` or target directories contain `.dll` files.\n\n### 3. Verify Tree-Shaking Stripping\nTo ensure the link hook is actually stripping unused native symbols and compressing binary packaging, perform the following validation:\n\n1. Compile a production bundle of the CLI\u002Fapp:\n   ```bash\n   dart build cli bin\u002Fmain.dart\n   ```\n2. Navigate to the compiled build directory containing the dynamic library.\n3. Query the exported dynamic symbol tables:\n   *   **macOS**:\n       ```bash\n       nm -gU build\u002Fcli\u002Flib\u002Flibsqlite3.dylib\n       ```\n   *   **Linux**:\n       ```bash\n       nm -D build\u002Fcli\u002Flib\u002Flibsqlite3.so\n       ```\n   *   **Windows** (using MSVC Developer Command Prompt):\n       ```cmd\n       dumpbin \u002FEXPORTS build\\cli\\lib\\sqlite3.dll\n       ```\n4. **Confirm Target Exports**: Verify that the command outputs **only** the explicitly kept entry point functions (e.g. `sqlite3_libversion`) and does not output any unreferenced\u002Fstripped symbols.\n5. **No Bundle Scenario**: If the application does not import or invoke any methods from the native library:\n   - Verify that the link hook logs: `Skipping linking as no symbols are to be kept.`\n   - Verify that no library was built\u002Fplaced in the production bundle (the `.dylib`\u002F`.so`\u002F`.dll` file is not generated, saving bundle size).\n\n### 4. Verify Offline Compliance (User Defines)\nConfirm offline compliance is fully active and the download fallback executes perfectly offline:\n\n1. Configure the `local_build: true` define for your package in the package's `pubspec.yaml` (or the workspace root `pubspec.yaml`):\n   ```yaml\n   hooks:\n     user_defines:\n       \u003Cyour_package_name>:\n         local_build: true\n   ```\n2. Disable the machine's network adapter or run in a sandboxed offline shell.\n3. Launch unit tests:\n   ```bash\n   dart test\n   ```\n4. Verify the test suite successfully compiles local source files using host compilers, has no compile errors, and never attempts network download requests.\n",{"data":33,"body":37},{"name":4,"description":6,"metadata":34},{"model":35,"last_modified":36},"models\u002Fgemini-3.1-pro-preview","Fri, 29 May 2026 09:10:00 GMT",{"type":38,"children":39},"root",[40,49,70,77,263,267,272,335,361,364,369,400,592,595,600,611,757,760,765,772,784,789,846,859,995,1001,1014,1020,1038,1044,1049,1068,1071,1076,1081,1192,1195,1200,1212,1217,1236,1333,1342,1347,1367,1427,1455,1510,1515,1526,1596,1607,1649,1818,1828,1847,2009,2012,2017,2030,2035,2068,2071,2076,2102,2117,2122,2168,2181,2186,2486,2497,2502,2887,2890,2895,2900,2905,2910,2927,2932,2937,3004,3009,3014,3228,3233,3238,3361],{"type":41,"tag":42,"props":43,"children":45},"element","h1",{"id":44},"compiling-c-code-into-code-assets-with-native-assets-hooks",[46],{"type":47,"value":48},"text","Compiling C Code into Code Assets with Native Assets Hooks",{"type":41,"tag":50,"props":51,"children":52},"p",{},[53,55,61,63,68],{"type":47,"value":54},"Integrate and automate the compilation and packaging of native C\u002FC++ source code into ",{"type":41,"tag":56,"props":57,"children":58},"strong",{},[59],{"type":47,"value":60},"Code Assets",{"type":47,"value":62}," under Dart's overarching ",{"type":41,"tag":56,"props":64,"children":65},{},[66],{"type":47,"value":67},"Native Assets",{"type":47,"value":69}," feature using build and link hooks.",{"type":41,"tag":71,"props":72,"children":74},"h2",{"id":73},"contents",[75],{"type":47,"value":76},"Contents",{"type":41,"tag":78,"props":79,"children":80},"ul",{},[81,92,101,110,119,128,185,215],{"type":41,"tag":82,"props":83,"children":84},"li",{},[85],{"type":41,"tag":86,"props":87,"children":89},"a",{"href":88},"#introduction",[90],{"type":47,"value":91},"Introduction",{"type":41,"tag":82,"props":93,"children":94},{},[95],{"type":41,"tag":86,"props":96,"children":98},{"href":97},"#constraints",[99],{"type":47,"value":100},"Constraints",{"type":41,"tag":82,"props":102,"children":103},{},[104],{"type":41,"tag":86,"props":105,"children":107},{"href":106},"#native-interop-packages",[108],{"type":47,"value":109},"Native Interop Packages",{"type":41,"tag":82,"props":111,"children":112},{},[113],{"type":41,"tag":86,"props":114,"children":116},{"href":115},"#step-by-step-workflow",[117],{"type":47,"value":118},"Step-by-Step Workflow",{"type":41,"tag":82,"props":120,"children":121},{},[122],{"type":41,"tag":86,"props":123,"children":125},{"href":124},"#choosing-an-integration-approach",[126],{"type":47,"value":127},"Choosing an Integration Approach",{"type":41,"tag":82,"props":129,"children":130},{},[131,137],{"type":41,"tag":86,"props":132,"children":134},{"href":133},"#method-1-local-compilation-with-linker-tree-shaking-recommended",[135],{"type":47,"value":136},"Method 1: Local Compilation with Linker Tree-Shaking (Recommended)",{"type":41,"tag":78,"props":138,"children":139},{},[140,149,158,167,176],{"type":41,"tag":82,"props":141,"children":142},{},[143],{"type":41,"tag":86,"props":144,"children":146},{"href":145},"#prerequisite-host-compiler-toolchains",[147],{"type":47,"value":148},"Prerequisite Host Compiler Toolchains",{"type":41,"tag":82,"props":150,"children":151},{},[152],{"type":41,"tag":86,"props":153,"children":155},{"href":154},"#c-source-and-bindings-setup",[156],{"type":47,"value":157},"C Source and Bindings Setup",{"type":41,"tag":82,"props":159,"children":160},{},[161],{"type":41,"tag":86,"props":162,"children":164},{"href":163},"#defining-the-c-library-build-spec",[165],{"type":47,"value":166},"Defining the C Library Build Spec",{"type":41,"tag":82,"props":168,"children":169},{},[170],{"type":41,"tag":86,"props":171,"children":173},{"href":172},"#implementing-hookbuilddart",[174],{"type":47,"value":175},"Implementing hook\u002Fbuild.dart",{"type":41,"tag":82,"props":177,"children":178},{},[179],{"type":41,"tag":86,"props":180,"children":182},{"href":181},"#implementing-hooklinkdart",[183],{"type":47,"value":184},"Implementing hook\u002Flink.dart",{"type":41,"tag":82,"props":186,"children":187},{},[188,194],{"type":41,"tag":86,"props":189,"children":191},{"href":190},"#method-2-downloading-precompiled-dynamic-libraries",[192],{"type":47,"value":193},"Method 2: Downloading Precompiled Dynamic Libraries",{"type":41,"tag":78,"props":195,"children":196},{},[197,206],{"type":41,"tag":82,"props":198,"children":199},{},[200],{"type":41,"tag":86,"props":201,"children":203},{"href":202},"#why-download-precompiled-binaries",[204],{"type":47,"value":205},"Why Download Precompiled Binaries?",{"type":41,"tag":82,"props":207,"children":208},{},[209],{"type":41,"tag":86,"props":210,"children":212},{"href":211},"#implementing-precompiled-dynamic-downloads",[213],{"type":47,"value":214},"Implementing Precompiled Dynamic Downloads",{"type":41,"tag":82,"props":216,"children":217},{},[218,224],{"type":41,"tag":86,"props":219,"children":221},{"href":220},"#verification-checklist",[222],{"type":47,"value":223},"Verification Checklist",{"type":41,"tag":78,"props":225,"children":226},{},[227,236,245,254],{"type":41,"tag":82,"props":228,"children":229},{},[230],{"type":41,"tag":86,"props":231,"children":233},{"href":232},"#1-local-execution-sandbox",[234],{"type":47,"value":235},"1. Local Execution Sandbox",{"type":41,"tag":82,"props":237,"children":238},{},[239],{"type":41,"tag":86,"props":240,"children":242},{"href":241},"#2-verify-target-outputs",[243],{"type":47,"value":244},"2. Verify Target Outputs",{"type":41,"tag":82,"props":246,"children":247},{},[248],{"type":41,"tag":86,"props":249,"children":251},{"href":250},"#3-verify-tree-shaking-stripping",[252],{"type":47,"value":253},"3. Verify Tree-Shaking Stripping",{"type":41,"tag":82,"props":255,"children":256},{},[257],{"type":41,"tag":86,"props":258,"children":260},{"href":259},"#4-verify-offline-compliance-user-defines",[261],{"type":47,"value":262},"4. Verify Offline Compliance (User Defines)",{"type":41,"tag":264,"props":265,"children":266},"hr",{},[],{"type":41,"tag":71,"props":268,"children":270},{"id":269},"introduction",[271],{"type":47,"value":91},{"type":41,"tag":50,"props":273,"children":274},{},[275,277,281,283,287,289,296,298,304,305,311,313,319,321,325,327,333],{"type":47,"value":276},"Under Dart's ",{"type":41,"tag":56,"props":278,"children":279},{},[280],{"type":47,"value":67},{"type":47,"value":282}," feature, packages can package native code (like C\u002FC++ libraries) as ",{"type":41,"tag":56,"props":284,"children":285},{},[286],{"type":47,"value":60},{"type":47,"value":288}," and bundle them automatically during standard development cycles (e.g., ",{"type":41,"tag":290,"props":291,"children":293},"code",{"className":292},[],[294],{"type":47,"value":295},"dart run",{"type":47,"value":297},", ",{"type":41,"tag":290,"props":299,"children":301},{"className":300},[],[302],{"type":47,"value":303},"dart test",{"type":47,"value":297},{"type":41,"tag":290,"props":306,"children":308},{"className":307},[],[309],{"type":47,"value":310},"dart build",{"type":47,"value":312},", and ",{"type":41,"tag":290,"props":314,"children":316},{"className":315},[],[317],{"type":47,"value":318},"flutter run",{"type":47,"value":320},"). The packaging of ",{"type":41,"tag":56,"props":322,"children":323},{},[324],{"type":47,"value":60},{"type":47,"value":326}," is driven by two programmatic hook scripts placed inside a package's ",{"type":41,"tag":290,"props":328,"children":330},{"className":329},[],[331],{"type":47,"value":332},"hook\u002F",{"type":47,"value":334}," folder:",{"type":41,"tag":336,"props":337,"children":338},"ol",{},[339,350],{"type":41,"tag":82,"props":340,"children":341},{},[342,348],{"type":41,"tag":290,"props":343,"children":345},{"className":344},[],[346],{"type":47,"value":347},"hook\u002Fbuild.dart",{"type":47,"value":349},": Compiles local C sources to machine code or bundles prebuilt native binaries as code assets for a specific host\u002Ftarget architecture.",{"type":41,"tag":82,"props":351,"children":352},{},[353,359],{"type":41,"tag":290,"props":354,"children":356},{"className":355},[],[357],{"type":47,"value":358},"hook\u002Flink.dart",{"type":47,"value":360},": Links built code assets, applying advanced tree-shaking optimizations to strip unused native symbols and compress the runtime binary size.",{"type":41,"tag":264,"props":362,"children":363},{},[],{"type":41,"tag":71,"props":365,"children":367},{"id":366},"constraints",[368],{"type":47,"value":100},{"type":41,"tag":370,"props":371,"children":372},"blockquote",{},[373],{"type":41,"tag":50,"props":374,"children":375},{},[376,382,384,390,392,398],{"type":41,"tag":377,"props":378,"children":379},"span",{},[380],{"type":47,"value":381},"!IMPORTANT",{"type":47,"value":383},"\nKeep all file resolving platform-independent. Never hardcode absolute target paths, shell scripts, or system command variables. Always use ",{"type":41,"tag":290,"props":385,"children":387},{"className":386},[],[388],{"type":47,"value":389},"Platform.script.resolve()",{"type":47,"value":391}," or ",{"type":41,"tag":290,"props":393,"children":395},{"className":394},[],[396],{"type":47,"value":397},"Uri",{"type":47,"value":399},"-based resolution to ensure scripts are fully portable.",{"type":41,"tag":78,"props":401,"children":402},{},[403,443,500,510,552],{"type":41,"tag":82,"props":404,"children":405},{},[406,411,413,418,420],{"type":41,"tag":56,"props":407,"children":408},{},[409],{"type":47,"value":410},"Hook Locations",{"type":47,"value":412},": Compiling and packaging hooks must reside strictly inside the ",{"type":41,"tag":290,"props":414,"children":416},{"className":415},[],[417],{"type":47,"value":332},{"type":47,"value":419}," directory at the package's root:\n",{"type":41,"tag":78,"props":421,"children":422},{},[423,433],{"type":41,"tag":82,"props":424,"children":425},{},[426,431],{"type":41,"tag":290,"props":427,"children":429},{"className":428},[],[430],{"type":47,"value":347},{"type":47,"value":432}," (Build execution phase)",{"type":41,"tag":82,"props":434,"children":435},{},[436,441],{"type":41,"tag":290,"props":437,"children":439},{"className":438},[],[440],{"type":47,"value":358},{"type":47,"value":442}," (Optional packaging\u002Flinking\u002Ftree-shaking phase)",{"type":41,"tag":82,"props":444,"children":445},{},[446,451,453,459,461,467,469,475,477,483,484,490,492,498],{"type":41,"tag":56,"props":447,"children":448},{},[449],{"type":47,"value":450},"Compile Toolchain Standard",{"type":47,"value":452},": Use the programmatic APIs from ",{"type":41,"tag":290,"props":454,"children":456},{"className":455},[],[457],{"type":47,"value":458},"package:native_toolchain_c",{"type":47,"value":460}," (e.g. ",{"type":41,"tag":290,"props":462,"children":464},{"className":463},[],[465],{"type":47,"value":466},"CBuilder",{"type":47,"value":468}," and ",{"type":41,"tag":290,"props":470,"children":472},{"className":471},[],[473],{"type":47,"value":474},"CLibrary",{"type":47,"value":476},") to run compile toolchains. Never invoke raw ",{"type":41,"tag":290,"props":478,"children":480},{"className":479},[],[481],{"type":47,"value":482},"gcc",{"type":47,"value":297},{"type":41,"tag":290,"props":485,"children":487},{"className":486},[],[488],{"type":47,"value":489},"clang",{"type":47,"value":491},", or ",{"type":41,"tag":290,"props":493,"children":495},{"className":494},[],[496],{"type":47,"value":497},"msvc",{"type":47,"value":499}," via shell commands.",{"type":41,"tag":82,"props":501,"children":502},{},[503,508],{"type":41,"tag":56,"props":504,"children":505},{},[506],{"type":47,"value":507},"Preamble & License Headers",{"type":47,"value":509},": Every handcrafted and generated source file (including bindings, helpers, and hooks) must strictly contain the target package's copyright and licensing header.",{"type":41,"tag":82,"props":511,"children":512},{},[513,518,520,526,528,534,536,542,544,550],{"type":41,"tag":56,"props":514,"children":515},{},[516],{"type":47,"value":517},"Tree Shaking Mapping",{"type":47,"value":519},": If utilizing compiler tree-shaking, you must map the target Dart method names (e.g. ",{"type":41,"tag":290,"props":521,"children":523},{"className":522},[],[524],{"type":47,"value":525},"Method.name",{"type":47,"value":527},") back to their raw native C symbol names using a record use mapping generated by FFIgen. The mapping file must reside under ",{"type":41,"tag":290,"props":529,"children":531},{"className":530},[],[532],{"type":47,"value":533},"lib\u002Fsrc\u002Fthird_party\u002F",{"type":47,"value":535}," and strictly use the ",{"type":41,"tag":290,"props":537,"children":539},{"className":538},[],[540],{"type":47,"value":541},".g.dart",{"type":47,"value":543}," extension (e.g., ",{"type":41,"tag":290,"props":545,"children":547},{"className":546},[],[548],{"type":47,"value":549},"sqlite3.record_use_mapping.g.dart",{"type":47,"value":551},").",{"type":41,"tag":82,"props":553,"children":554},{},[555,560,562],{"type":41,"tag":56,"props":556,"children":557},{},[558],{"type":47,"value":559},"Integrity Safeguards for Precompiled Libraries",{"type":47,"value":561},": If adopting the dynamic download pattern:\n",{"type":41,"tag":78,"props":563,"children":564},{},[565,575],{"type":41,"tag":82,"props":566,"children":567},{},[568,573],{"type":41,"tag":56,"props":569,"children":570},{},[571],{"type":47,"value":572},"Cryptographic Verification",{"type":47,"value":574},": Downloaded prebuilt binaries must be checked against preconfigured lookup tables containing MD5 or SHA-256 hashes to guarantee binary integrity and prevent tampering.",{"type":41,"tag":82,"props":576,"children":577},{},[578,583,585,591],{"type":41,"tag":56,"props":579,"children":580},{},[581],{"type":47,"value":582},"Graceful Recovery",{"type":47,"value":584},": Support offline developers by providing fallbacks (such as local compiler execution via flags like ",{"type":41,"tag":290,"props":586,"children":588},{"className":587},[],[589],{"type":47,"value":590},"local_build",{"type":47,"value":551},{"type":41,"tag":264,"props":593,"children":594},{},[],{"type":41,"tag":71,"props":596,"children":598},{"id":597},"native-interop-packages",[599],{"type":47,"value":109},{"type":41,"tag":50,"props":601,"children":602},{},[603,605,609],{"type":47,"value":604},"Programmatic build and link hooks for ",{"type":41,"tag":56,"props":606,"children":607},{},[608],{"type":47,"value":60},{"type":47,"value":610}," leverage three specialized native interop packages:",{"type":41,"tag":612,"props":613,"children":614},"table",{},[615,640],{"type":41,"tag":616,"props":617,"children":618},"thead",{},[619],{"type":41,"tag":620,"props":621,"children":622},"tr",{},[623,630,635],{"type":41,"tag":624,"props":625,"children":627},"th",{"align":626},"left",[628],{"type":47,"value":629},"Dependency",{"type":41,"tag":624,"props":631,"children":632},{"align":626},[633],{"type":47,"value":634},"Purpose",{"type":41,"tag":624,"props":636,"children":637},{"align":626},[638],{"type":47,"value":639},"Key API Abstractions",{"type":41,"tag":641,"props":642,"children":643},"tbody",{},[644,681,721],{"type":41,"tag":620,"props":645,"children":646},{},[647,660,665],{"type":41,"tag":648,"props":649,"children":650},"td",{"align":626},[651],{"type":41,"tag":56,"props":652,"children":653},{},[654],{"type":41,"tag":290,"props":655,"children":657},{"className":656},[],[658],{"type":47,"value":659},"package:hooks",{"type":41,"tag":648,"props":661,"children":662},{"align":626},[663],{"type":47,"value":664},"Main orchestrator defining execution bounds.",{"type":41,"tag":648,"props":666,"children":667},{"align":626},[668,674,675],{"type":41,"tag":290,"props":669,"children":671},{"className":670},[],[672],{"type":47,"value":673},"build(args, callback)",{"type":47,"value":297},{"type":41,"tag":290,"props":676,"children":678},{"className":677},[],[679],{"type":47,"value":680},"link(args, callback)",{"type":41,"tag":620,"props":682,"children":683},{},[684,695,700],{"type":41,"tag":648,"props":685,"children":686},{"align":626},[687],{"type":41,"tag":56,"props":688,"children":689},{},[690],{"type":41,"tag":290,"props":691,"children":693},{"className":692},[],[694],{"type":47,"value":458},{"type":41,"tag":648,"props":696,"children":697},{"align":626},[698],{"type":47,"value":699},"Detects local compilers (MSVC, Xcode\u002FClang, GCC) and executes build toolchains.",{"type":41,"tag":648,"props":701,"children":702},{"align":626},[703,708,709,714,715],{"type":41,"tag":290,"props":704,"children":706},{"className":705},[],[707],{"type":47,"value":474},{"type":47,"value":297},{"type":41,"tag":290,"props":710,"children":712},{"className":711},[],[713],{"type":47,"value":466},{"type":47,"value":297},{"type":41,"tag":290,"props":716,"children":718},{"className":717},[],[719],{"type":47,"value":720},"LinkerOptions.treeshake",{"type":41,"tag":620,"props":722,"children":723},{},[724,736,741],{"type":41,"tag":648,"props":725,"children":726},{"align":626},[727],{"type":41,"tag":56,"props":728,"children":729},{},[730],{"type":41,"tag":290,"props":731,"children":733},{"className":732},[],[734],{"type":47,"value":735},"package:code_assets",{"type":41,"tag":648,"props":737,"children":738},{"align":626},[739],{"type":47,"value":740},"Models code metadata records passed to dynamic loaders.",{"type":41,"tag":648,"props":742,"children":743},{"align":626},[744,750,751],{"type":41,"tag":290,"props":745,"children":747},{"className":746},[],[748],{"type":47,"value":749},"CodeAsset",{"type":47,"value":297},{"type":41,"tag":290,"props":752,"children":754},{"className":753},[],[755],{"type":47,"value":756},"DynamicLoadingBundled",{"type":41,"tag":264,"props":758,"children":759},{},[],{"type":41,"tag":71,"props":761,"children":763},{"id":762},"step-by-step-workflow",[764],{"type":47,"value":118},{"type":41,"tag":766,"props":767,"children":769},"h3",{"id":768},"step-1-add-dependencies",[770],{"type":47,"value":771},"Step 1: Add Dependencies",{"type":41,"tag":50,"props":773,"children":774},{},[775,777,782],{"type":47,"value":776},"Add Code Assets hook and toolchain dependencies to your package. You must fetch these dependencies directly from ",{"type":41,"tag":56,"props":778,"children":779},{},[780],{"type":47,"value":781},"pub.dev",{"type":47,"value":783},".",{"type":41,"tag":50,"props":785,"children":786},{},[787],{"type":47,"value":788},"You can add it automatically using the CLI:",{"type":41,"tag":790,"props":791,"children":796},"pre",{"className":792,"code":793,"language":794,"meta":795,"style":795},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","dart pub add code_assets hooks native_toolchain_c record_use dev:ffigen\n","bash","",[797],{"type":41,"tag":290,"props":798,"children":799},{"__ignoreMap":795},[800],{"type":41,"tag":377,"props":801,"children":804},{"class":802,"line":803},"line",1,[805,810,816,821,826,831,836,841],{"type":41,"tag":377,"props":806,"children":808},{"style":807},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[809],{"type":47,"value":21},{"type":41,"tag":377,"props":811,"children":813},{"style":812},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[814],{"type":47,"value":815}," pub",{"type":41,"tag":377,"props":817,"children":818},{"style":812},[819],{"type":47,"value":820}," add",{"type":41,"tag":377,"props":822,"children":823},{"style":812},[824],{"type":47,"value":825}," code_assets",{"type":41,"tag":377,"props":827,"children":828},{"style":812},[829],{"type":47,"value":830}," hooks",{"type":41,"tag":377,"props":832,"children":833},{"style":812},[834],{"type":47,"value":835}," native_toolchain_c",{"type":41,"tag":377,"props":837,"children":838},{"style":812},[839],{"type":47,"value":840}," record_use",{"type":41,"tag":377,"props":842,"children":843},{"style":812},[844],{"type":47,"value":845}," dev:ffigen\n",{"type":41,"tag":50,"props":847,"children":848},{},[849,851,857],{"type":47,"value":850},"Or manually declare them in your target package's ",{"type":41,"tag":290,"props":852,"children":854},{"className":853},[],[855],{"type":47,"value":856},"pubspec.yaml",{"type":47,"value":858},":",{"type":41,"tag":790,"props":860,"children":864},{"className":861,"code":862,"language":863,"meta":795,"style":795},"language-yaml shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","dependencies:\n  code_assets: ^1.0.0\n  hooks: ^0.1.0\n  native_toolchain_c: ^0.1.0\n  record_use: ^0.6.0\n\ndev_dependencies:\n  ffigen: ^20.1.1\n","yaml",[865],{"type":41,"tag":290,"props":866,"children":867},{"__ignoreMap":795},[868,883,901,919,936,954,964,977],{"type":41,"tag":377,"props":869,"children":870},{"class":802,"line":803},[871,877],{"type":41,"tag":377,"props":872,"children":874},{"style":873},"--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178",[875],{"type":47,"value":876},"dependencies",{"type":41,"tag":377,"props":878,"children":880},{"style":879},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[881],{"type":47,"value":882},":\n",{"type":41,"tag":377,"props":884,"children":886},{"class":802,"line":885},2,[887,892,896],{"type":41,"tag":377,"props":888,"children":889},{"style":873},[890],{"type":47,"value":891},"  code_assets",{"type":41,"tag":377,"props":893,"children":894},{"style":879},[895],{"type":47,"value":858},{"type":41,"tag":377,"props":897,"children":898},{"style":812},[899],{"type":47,"value":900}," ^1.0.0\n",{"type":41,"tag":377,"props":902,"children":904},{"class":802,"line":903},3,[905,910,914],{"type":41,"tag":377,"props":906,"children":907},{"style":873},[908],{"type":47,"value":909},"  hooks",{"type":41,"tag":377,"props":911,"children":912},{"style":879},[913],{"type":47,"value":858},{"type":41,"tag":377,"props":915,"children":916},{"style":812},[917],{"type":47,"value":918}," ^0.1.0\n",{"type":41,"tag":377,"props":920,"children":922},{"class":802,"line":921},4,[923,928,932],{"type":41,"tag":377,"props":924,"children":925},{"style":873},[926],{"type":47,"value":927},"  native_toolchain_c",{"type":41,"tag":377,"props":929,"children":930},{"style":879},[931],{"type":47,"value":858},{"type":41,"tag":377,"props":933,"children":934},{"style":812},[935],{"type":47,"value":918},{"type":41,"tag":377,"props":937,"children":939},{"class":802,"line":938},5,[940,945,949],{"type":41,"tag":377,"props":941,"children":942},{"style":873},[943],{"type":47,"value":944},"  record_use",{"type":41,"tag":377,"props":946,"children":947},{"style":879},[948],{"type":47,"value":858},{"type":41,"tag":377,"props":950,"children":951},{"style":812},[952],{"type":47,"value":953}," ^0.6.0\n",{"type":41,"tag":377,"props":955,"children":957},{"class":802,"line":956},6,[958],{"type":41,"tag":377,"props":959,"children":961},{"emptyLinePlaceholder":960},true,[962],{"type":47,"value":963},"\n",{"type":41,"tag":377,"props":965,"children":967},{"class":802,"line":966},7,[968,973],{"type":41,"tag":377,"props":969,"children":970},{"style":873},[971],{"type":47,"value":972},"dev_dependencies",{"type":41,"tag":377,"props":974,"children":975},{"style":879},[976],{"type":47,"value":882},{"type":41,"tag":377,"props":978,"children":980},{"class":802,"line":979},8,[981,986,990],{"type":41,"tag":377,"props":982,"children":983},{"style":873},[984],{"type":47,"value":985},"  ffigen",{"type":41,"tag":377,"props":987,"children":988},{"style":879},[989],{"type":47,"value":858},{"type":41,"tag":377,"props":991,"children":992},{"style":812},[993],{"type":47,"value":994}," ^20.1.1\n",{"type":41,"tag":766,"props":996,"children":998},{"id":997},"step-2-define-c-specifications",[999],{"type":47,"value":1000},"Step 2: Define C Specifications",{"type":41,"tag":50,"props":1002,"children":1003},{},[1004,1006,1012],{"type":47,"value":1005},"Define your target C library compilation metadata inside ",{"type":41,"tag":290,"props":1007,"children":1009},{"className":1008},[],[1010],{"type":47,"value":1011},"lib\u002Fsrc\u002Fc_library.dart",{"type":47,"value":1013},". This lets both the build and link hooks share a single source of truth for assets, names, and sources.",{"type":41,"tag":766,"props":1015,"children":1017},{"id":1016},"step-3-implement-build-and-link-hook-scripts",[1018],{"type":47,"value":1019},"Step 3: Implement Build and Link Hook Scripts",{"type":41,"tag":50,"props":1021,"children":1022},{},[1023,1025,1030,1032,1037],{"type":47,"value":1024},"Write the compilation orchestration script inside ",{"type":41,"tag":290,"props":1026,"children":1028},{"className":1027},[],[1029],{"type":47,"value":347},{"type":47,"value":1031}," and the dead-code elimination logic inside ",{"type":41,"tag":290,"props":1033,"children":1035},{"className":1034},[],[1036],{"type":47,"value":358},{"type":47,"value":783},{"type":41,"tag":766,"props":1039,"children":1041},{"id":1040},"step-4-run-the-hook-cycle",[1042],{"type":47,"value":1043},"Step 4: Run the Hook Cycle",{"type":41,"tag":50,"props":1045,"children":1046},{},[1047],{"type":47,"value":1048},"Running standard test suites dynamically launches the build and link hook lifecycle in the background:",{"type":41,"tag":790,"props":1050,"children":1052},{"className":792,"code":1051,"language":794,"meta":795,"style":795},"dart test\n",[1053],{"type":41,"tag":290,"props":1054,"children":1055},{"__ignoreMap":795},[1056],{"type":41,"tag":377,"props":1057,"children":1058},{"class":802,"line":803},[1059,1063],{"type":41,"tag":377,"props":1060,"children":1061},{"style":807},[1062],{"type":47,"value":21},{"type":41,"tag":377,"props":1064,"children":1065},{"style":812},[1066],{"type":47,"value":1067}," test\n",{"type":41,"tag":264,"props":1069,"children":1070},{},[],{"type":41,"tag":71,"props":1072,"children":1074},{"id":1073},"choosing-an-integration-approach",[1075],{"type":47,"value":127},{"type":41,"tag":50,"props":1077,"children":1078},{},[1079],{"type":47,"value":1080},"There are two primary methods for integrating and delivering C\u002FC++ native assets in Dart. Select the one that matches your project requirements:",{"type":41,"tag":612,"props":1082,"children":1083},{},[1084,1105],{"type":41,"tag":616,"props":1085,"children":1086},{},[1087],{"type":41,"tag":620,"props":1088,"children":1089},{},[1090,1095,1100],{"type":41,"tag":624,"props":1091,"children":1092},{"align":626},[1093],{"type":47,"value":1094},"Aspect",{"type":41,"tag":624,"props":1096,"children":1097},{"align":626},[1098],{"type":47,"value":1099},"Method 1: Local Compilation & Tree-Shaking",{"type":41,"tag":624,"props":1101,"children":1102},{"align":626},[1103],{"type":47,"value":1104},"Method 2: Precompiled Downloads",{"type":41,"tag":641,"props":1106,"children":1107},{},[1108,1129,1150,1171],{"type":41,"tag":620,"props":1109,"children":1110},{},[1111,1119,1124],{"type":41,"tag":648,"props":1112,"children":1113},{"align":626},[1114],{"type":41,"tag":56,"props":1115,"children":1116},{},[1117],{"type":47,"value":1118},"Primary Use Case",{"type":41,"tag":648,"props":1120,"children":1121},{"align":626},[1122],{"type":47,"value":1123},"When C\u002FC++ source code is included directly in the package and you want maximum size optimization.",{"type":41,"tag":648,"props":1125,"children":1126},{"align":626},[1127],{"type":47,"value":1128},"When compiling locally is slow\u002Fcomplex, or when avoiding developer host toolchain requirements.",{"type":41,"tag":620,"props":1130,"children":1131},{},[1132,1140,1145],{"type":41,"tag":648,"props":1133,"children":1134},{"align":626},[1135],{"type":41,"tag":56,"props":1136,"children":1137},{},[1138],{"type":47,"value":1139},"Host Toolchain Requirements",{"type":41,"tag":648,"props":1141,"children":1142},{"align":626},[1143],{"type":47,"value":1144},"Requires pre-installed platform C compiler (Xcode tools, MSVC, GCC).",{"type":41,"tag":648,"props":1146,"children":1147},{"align":626},[1148],{"type":47,"value":1149},"Zero compiler setup required on developer\u002Fuser machines.",{"type":41,"tag":620,"props":1151,"children":1152},{},[1153,1161,1166],{"type":41,"tag":648,"props":1154,"children":1155},{"align":626},[1156],{"type":41,"tag":56,"props":1157,"children":1158},{},[1159],{"type":47,"value":1160},"Binary Optimization",{"type":41,"tag":648,"props":1162,"children":1163},{"align":626},[1164],{"type":47,"value":1165},"Premium. Unused symbols are completely tree-shaken, decreasing library size.",{"type":41,"tag":648,"props":1167,"children":1168},{"align":626},[1169],{"type":47,"value":1170},"Standard. Standard compiled binaries are shipped as-is.",{"type":41,"tag":620,"props":1172,"children":1173},{},[1174,1182,1187],{"type":41,"tag":648,"props":1175,"children":1176},{"align":626},[1177],{"type":41,"tag":56,"props":1178,"children":1179},{},[1180],{"type":47,"value":1181},"Offline Setup",{"type":41,"tag":648,"props":1183,"children":1184},{"align":626},[1185],{"type":47,"value":1186},"Fully compliant. Works completely offline.",{"type":41,"tag":648,"props":1188,"children":1189},{"align":626},[1190],{"type":47,"value":1191},"Requires network access to download libraries, with offline fallback.",{"type":41,"tag":264,"props":1193,"children":1194},{},[],{"type":41,"tag":71,"props":1196,"children":1198},{"id":1197},"method-1-local-compilation-with-linker-tree-shaking-recommended",[1199],{"type":47,"value":136},{"type":41,"tag":50,"props":1201,"children":1202},{},[1203,1205,1211],{"type":47,"value":1204},"In this approach, the build hook invokes local toolchains (GCC, Clang, MSVC) to compile source files directly. The link hook subsequently filters output symbols utilizing compiler options, retaining only target methods invoked in user code. This represents the standard, robust SQLite pattern under ",{"type":41,"tag":290,"props":1206,"children":1208},{"className":1207},[],[1209],{"type":47,"value":1210},"pkgs\u002Fcode_assets\u002Fexample\u002Fsqlite",{"type":47,"value":783},{"type":41,"tag":766,"props":1213,"children":1215},{"id":1214},"prerequisite-host-compiler-toolchains",[1216],{"type":47,"value":148},{"type":41,"tag":50,"props":1218,"children":1219},{},[1220,1222,1227,1229,1234],{"type":47,"value":1221},"Since ",{"type":41,"tag":290,"props":1223,"children":1225},{"className":1224},[],[1226],{"type":47,"value":458},{"type":47,"value":1228}," delegates actual dynamic compilation to the host operating system's default toolchain, the development machine ",{"type":41,"tag":56,"props":1230,"children":1231},{},[1232],{"type":47,"value":1233},"must",{"type":47,"value":1235}," have one of the following compiler packages pre-installed:",{"type":41,"tag":78,"props":1237,"children":1238},{},[1239,1269,1309],{"type":41,"tag":82,"props":1240,"children":1241},{},[1242,1247,1249],{"type":41,"tag":56,"props":1243,"children":1244},{},[1245],{"type":47,"value":1246},"macOS",{"type":47,"value":1248},": Xcode Command Line Tools. Install via:\n",{"type":41,"tag":790,"props":1250,"children":1252},{"className":792,"code":1251,"language":794,"meta":795,"style":795},"xcode-select --install\n",[1253],{"type":41,"tag":290,"props":1254,"children":1255},{"__ignoreMap":795},[1256],{"type":41,"tag":377,"props":1257,"children":1258},{"class":802,"line":803},[1259,1264],{"type":41,"tag":377,"props":1260,"children":1261},{"style":807},[1262],{"type":47,"value":1263},"xcode-select",{"type":41,"tag":377,"props":1265,"children":1266},{"style":812},[1267],{"type":47,"value":1268}," --install\n",{"type":41,"tag":82,"props":1270,"children":1271},{},[1272,1277,1279],{"type":41,"tag":56,"props":1273,"children":1274},{},[1275],{"type":47,"value":1276},"Linux",{"type":47,"value":1278},": GCC or Clang. Install via:\n",{"type":41,"tag":790,"props":1280,"children":1282},{"className":792,"code":1281,"language":794,"meta":795,"style":795},"sudo apt install build-essential\n",[1283],{"type":41,"tag":290,"props":1284,"children":1285},{"__ignoreMap":795},[1286],{"type":41,"tag":377,"props":1287,"children":1288},{"class":802,"line":803},[1289,1294,1299,1304],{"type":41,"tag":377,"props":1290,"children":1291},{"style":807},[1292],{"type":47,"value":1293},"sudo",{"type":41,"tag":377,"props":1295,"children":1296},{"style":812},[1297],{"type":47,"value":1298}," apt",{"type":41,"tag":377,"props":1300,"children":1301},{"style":812},[1302],{"type":47,"value":1303}," install",{"type":41,"tag":377,"props":1305,"children":1306},{"style":812},[1307],{"type":47,"value":1308}," build-essential\n",{"type":41,"tag":82,"props":1310,"children":1311},{},[1312,1317,1319,1324,1326,1331],{"type":41,"tag":56,"props":1313,"children":1314},{},[1315],{"type":47,"value":1316},"Windows",{"type":47,"value":1318},": MSVC (Microsoft Visual C++). Install the ",{"type":41,"tag":56,"props":1320,"children":1321},{},[1322],{"type":47,"value":1323},"Visual Studio Installer",{"type":47,"value":1325}," and select the ",{"type":41,"tag":56,"props":1327,"children":1328},{},[1329],{"type":47,"value":1330},"Desktop development with C++",{"type":47,"value":1332}," workload.",{"type":41,"tag":50,"props":1334,"children":1335},{},[1336],{"type":41,"tag":1337,"props":1338,"children":1339},"em",{},[1340],{"type":47,"value":1341},"Note: If no compatible toolchain is discovered on the host path, the build hook script will throw a compilation execution exception. Ensure to specify compiler constraints or adopt Method 2 if toolchains cannot be guaranteed.",{"type":41,"tag":766,"props":1343,"children":1345},{"id":1344},"c-source-and-bindings-setup",[1346],{"type":47,"value":157},{"type":41,"tag":50,"props":1348,"children":1349},{},[1350,1352,1358,1360,1366],{"type":47,"value":1351},"Assume a C source defining simple math functions at ",{"type":41,"tag":290,"props":1353,"children":1355},{"className":1354},[],[1356],{"type":47,"value":1357},"third_party\u002Fsqlite\u002Fsqlite3.c",{"type":47,"value":1359}," with its entry point header at ",{"type":41,"tag":290,"props":1361,"children":1363},{"className":1362},[],[1364],{"type":47,"value":1365},"third_party\u002Fsqlite\u002Fsqlite3.h",{"type":47,"value":858},{"type":41,"tag":790,"props":1368,"children":1372},{"className":1369,"code":1370,"language":1371,"meta":795,"style":795},"language-c shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","#ifndef SQLITE3_H_\n#define SQLITE3_H_\n\nconst char *sqlite3_libversion(void);\n\n#endif \u002F\u002F SQLITE3_H_\n","c",[1373],{"type":41,"tag":290,"props":1374,"children":1375},{"__ignoreMap":795},[1376,1384,1392,1399,1407,1414],{"type":41,"tag":377,"props":1377,"children":1378},{"class":802,"line":803},[1379],{"type":41,"tag":377,"props":1380,"children":1381},{},[1382],{"type":47,"value":1383},"#ifndef SQLITE3_H_\n",{"type":41,"tag":377,"props":1385,"children":1386},{"class":802,"line":885},[1387],{"type":41,"tag":377,"props":1388,"children":1389},{},[1390],{"type":47,"value":1391},"#define SQLITE3_H_\n",{"type":41,"tag":377,"props":1393,"children":1394},{"class":802,"line":903},[1395],{"type":41,"tag":377,"props":1396,"children":1397},{"emptyLinePlaceholder":960},[1398],{"type":47,"value":963},{"type":41,"tag":377,"props":1400,"children":1401},{"class":802,"line":921},[1402],{"type":41,"tag":377,"props":1403,"children":1404},{},[1405],{"type":47,"value":1406},"const char *sqlite3_libversion(void);\n",{"type":41,"tag":377,"props":1408,"children":1409},{"class":802,"line":938},[1410],{"type":41,"tag":377,"props":1411,"children":1412},{"emptyLinePlaceholder":960},[1413],{"type":47,"value":963},{"type":41,"tag":377,"props":1415,"children":1416},{"class":802,"line":956},[1417,1422],{"type":41,"tag":377,"props":1418,"children":1419},{},[1420],{"type":47,"value":1421},"#endif",{"type":41,"tag":377,"props":1423,"children":1424},{},[1425],{"type":47,"value":1426}," \u002F\u002F SQLITE3_H_\n",{"type":41,"tag":50,"props":1428,"children":1429},{},[1430,1432,1438,1440,1446,1448,1454],{"type":47,"value":1431},"We utilize a programmatic FFIgen script (",{"type":41,"tag":290,"props":1433,"children":1435},{"className":1434},[],[1436],{"type":47,"value":1437},"tool\u002Fffigen.dart",{"type":47,"value":1439},") to create FFI bindings in ",{"type":41,"tag":290,"props":1441,"children":1443},{"className":1442},[],[1444],{"type":47,"value":1445},"lib\u002Fsrc\u002Fthird_party\u002Fsqlite3.g.dart",{"type":47,"value":1447},", enabling recorded usage tracking and producing the lookup metadata map in ",{"type":41,"tag":290,"props":1449,"children":1451},{"className":1450},[],[1452],{"type":47,"value":1453},"lib\u002Fsrc\u002Fthird_party\u002Fsqlite3.record_use_mapping.g.dart",{"type":47,"value":858},{"type":41,"tag":790,"props":1456,"children":1459},{"className":1457,"code":1458,"language":21,"meta":795,"style":795},"language-dart shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F AUTO-GENERATED FILE - DO NOT MODIFY.\n\u002F\u002F Generated via ffigen.\n\nconst recordUseMapping = {\n  'sqlite3_libversion': 'sqlite3_libversion',\n};\n",[1460],{"type":41,"tag":290,"props":1461,"children":1462},{"__ignoreMap":795},[1463,1471,1479,1486,1494,1502],{"type":41,"tag":377,"props":1464,"children":1465},{"class":802,"line":803},[1466],{"type":41,"tag":377,"props":1467,"children":1468},{},[1469],{"type":47,"value":1470},"\u002F\u002F AUTO-GENERATED FILE - DO NOT MODIFY.\n",{"type":41,"tag":377,"props":1472,"children":1473},{"class":802,"line":885},[1474],{"type":41,"tag":377,"props":1475,"children":1476},{},[1477],{"type":47,"value":1478},"\u002F\u002F Generated via ffigen.\n",{"type":41,"tag":377,"props":1480,"children":1481},{"class":802,"line":903},[1482],{"type":41,"tag":377,"props":1483,"children":1484},{"emptyLinePlaceholder":960},[1485],{"type":47,"value":963},{"type":41,"tag":377,"props":1487,"children":1488},{"class":802,"line":921},[1489],{"type":41,"tag":377,"props":1490,"children":1491},{},[1492],{"type":47,"value":1493},"const recordUseMapping = {\n",{"type":41,"tag":377,"props":1495,"children":1496},{"class":802,"line":938},[1497],{"type":41,"tag":377,"props":1498,"children":1499},{},[1500],{"type":47,"value":1501},"  'sqlite3_libversion': 'sqlite3_libversion',\n",{"type":41,"tag":377,"props":1503,"children":1504},{"class":802,"line":956},[1505],{"type":41,"tag":377,"props":1506,"children":1507},{},[1508],{"type":47,"value":1509},"};\n",{"type":41,"tag":766,"props":1511,"children":1513},{"id":1512},"defining-the-c-library-build-spec",[1514],{"type":47,"value":166},{"type":41,"tag":50,"props":1516,"children":1517},{},[1518,1520,1525],{"type":47,"value":1519},"Define the centralized library specification in ",{"type":41,"tag":290,"props":1521,"children":1523},{"className":1522},[],[1524],{"type":47,"value":1011},{"type":47,"value":858},{"type":41,"tag":790,"props":1527,"children":1529},{"className":1457,"code":1528,"language":21,"meta":795,"style":795},"import 'package:native_toolchain_c\u002Fnative_toolchain_c.dart';\n\n\u002F\u002F\u002F The C build specification for the sqlite library.\nfinal cLibrary = CLibrary(\n  name: 'sqlite3',\n  assetName: 'src\u002Fthird_party\u002Fsqlite3.g.dart',\n  sources: ['third_party\u002Fsqlite\u002Fsqlite3.c'],\n);\n",[1530],{"type":41,"tag":290,"props":1531,"children":1532},{"__ignoreMap":795},[1533,1541,1548,1556,1564,1572,1580,1588],{"type":41,"tag":377,"props":1534,"children":1535},{"class":802,"line":803},[1536],{"type":41,"tag":377,"props":1537,"children":1538},{},[1539],{"type":47,"value":1540},"import 'package:native_toolchain_c\u002Fnative_toolchain_c.dart';\n",{"type":41,"tag":377,"props":1542,"children":1543},{"class":802,"line":885},[1544],{"type":41,"tag":377,"props":1545,"children":1546},{"emptyLinePlaceholder":960},[1547],{"type":47,"value":963},{"type":41,"tag":377,"props":1549,"children":1550},{"class":802,"line":903},[1551],{"type":41,"tag":377,"props":1552,"children":1553},{},[1554],{"type":47,"value":1555},"\u002F\u002F\u002F The C build specification for the sqlite library.\n",{"type":41,"tag":377,"props":1557,"children":1558},{"class":802,"line":921},[1559],{"type":41,"tag":377,"props":1560,"children":1561},{},[1562],{"type":47,"value":1563},"final cLibrary = CLibrary(\n",{"type":41,"tag":377,"props":1565,"children":1566},{"class":802,"line":938},[1567],{"type":41,"tag":377,"props":1568,"children":1569},{},[1570],{"type":47,"value":1571},"  name: 'sqlite3',\n",{"type":41,"tag":377,"props":1573,"children":1574},{"class":802,"line":956},[1575],{"type":41,"tag":377,"props":1576,"children":1577},{},[1578],{"type":47,"value":1579},"  assetName: 'src\u002Fthird_party\u002Fsqlite3.g.dart',\n",{"type":41,"tag":377,"props":1581,"children":1582},{"class":802,"line":966},[1583],{"type":41,"tag":377,"props":1584,"children":1585},{},[1586],{"type":47,"value":1587},"  sources: ['third_party\u002Fsqlite\u002Fsqlite3.c'],\n",{"type":41,"tag":377,"props":1589,"children":1590},{"class":802,"line":979},[1591],{"type":41,"tag":377,"props":1592,"children":1593},{},[1594],{"type":47,"value":1595},");\n",{"type":41,"tag":766,"props":1597,"children":1599},{"id":1598},"implementing-hookbuilddart",[1600,1602],{"type":47,"value":1601},"Implementing ",{"type":41,"tag":290,"props":1603,"children":1605},{"className":1604},[],[1606],{"type":47,"value":347},{"type":41,"tag":50,"props":1608,"children":1609},{},[1610,1612,1617,1619,1625,1627,1633,1634,1640,1641,1647],{"type":47,"value":1611},"Implement ",{"type":41,"tag":290,"props":1613,"children":1615},{"className":1614},[],[1616],{"type":47,"value":347},{"type":47,"value":1618}," using ",{"type":41,"tag":290,"props":1620,"children":1622},{"className":1621},[],[1623],{"type":47,"value":1624},"CLibrary.build",{"type":47,"value":1626},". This builds the library to a dynamic library (e.g. ",{"type":41,"tag":290,"props":1628,"children":1630},{"className":1629},[],[1631],{"type":47,"value":1632},".so",{"type":47,"value":297},{"type":41,"tag":290,"props":1635,"children":1637},{"className":1636},[],[1638],{"type":47,"value":1639},".dylib",{"type":47,"value":491},{"type":41,"tag":290,"props":1642,"children":1644},{"className":1643},[],[1645],{"type":47,"value":1646},".dll",{"type":47,"value":1648},") inside the hook's target directory:",{"type":41,"tag":790,"props":1650,"children":1652},{"className":1457,"code":1651,"language":21,"meta":795,"style":795},"import 'package:code_assets\u002Fcode_assets.dart';\nimport 'package:hooks\u002Fhooks.dart';\nimport 'package:sqlite\u002Fsrc\u002Fc_library.dart';\n\nvoid main(List\u003CString> args) async {\n  await build(args, (input, output) async {\n    if (input.config.buildCodeAssets) {\n      await cLibrary.build(\n        input: input,\n        output: output,\n        defines: {\n          if (input.config.code.targetOS == OS.windows)\n            \u002F\u002F Ensure C functions are explicitly exported in the Windows DLL\n            'SQLITE_API': '__declspec(dllexport)',\n        },\n      );\n    }\n  });\n}\n",[1653],{"type":41,"tag":290,"props":1654,"children":1655},{"__ignoreMap":795},[1656,1664,1672,1680,1687,1695,1703,1711,1719,1728,1737,1746,1755,1764,1773,1782,1791,1800,1809],{"type":41,"tag":377,"props":1657,"children":1658},{"class":802,"line":803},[1659],{"type":41,"tag":377,"props":1660,"children":1661},{},[1662],{"type":47,"value":1663},"import 'package:code_assets\u002Fcode_assets.dart';\n",{"type":41,"tag":377,"props":1665,"children":1666},{"class":802,"line":885},[1667],{"type":41,"tag":377,"props":1668,"children":1669},{},[1670],{"type":47,"value":1671},"import 'package:hooks\u002Fhooks.dart';\n",{"type":41,"tag":377,"props":1673,"children":1674},{"class":802,"line":903},[1675],{"type":41,"tag":377,"props":1676,"children":1677},{},[1678],{"type":47,"value":1679},"import 'package:sqlite\u002Fsrc\u002Fc_library.dart';\n",{"type":41,"tag":377,"props":1681,"children":1682},{"class":802,"line":921},[1683],{"type":41,"tag":377,"props":1684,"children":1685},{"emptyLinePlaceholder":960},[1686],{"type":47,"value":963},{"type":41,"tag":377,"props":1688,"children":1689},{"class":802,"line":938},[1690],{"type":41,"tag":377,"props":1691,"children":1692},{},[1693],{"type":47,"value":1694},"void main(List\u003CString> args) async {\n",{"type":41,"tag":377,"props":1696,"children":1697},{"class":802,"line":956},[1698],{"type":41,"tag":377,"props":1699,"children":1700},{},[1701],{"type":47,"value":1702},"  await build(args, (input, output) async {\n",{"type":41,"tag":377,"props":1704,"children":1705},{"class":802,"line":966},[1706],{"type":41,"tag":377,"props":1707,"children":1708},{},[1709],{"type":47,"value":1710},"    if (input.config.buildCodeAssets) {\n",{"type":41,"tag":377,"props":1712,"children":1713},{"class":802,"line":979},[1714],{"type":41,"tag":377,"props":1715,"children":1716},{},[1717],{"type":47,"value":1718},"      await cLibrary.build(\n",{"type":41,"tag":377,"props":1720,"children":1722},{"class":802,"line":1721},9,[1723],{"type":41,"tag":377,"props":1724,"children":1725},{},[1726],{"type":47,"value":1727},"        input: input,\n",{"type":41,"tag":377,"props":1729,"children":1731},{"class":802,"line":1730},10,[1732],{"type":41,"tag":377,"props":1733,"children":1734},{},[1735],{"type":47,"value":1736},"        output: output,\n",{"type":41,"tag":377,"props":1738,"children":1740},{"class":802,"line":1739},11,[1741],{"type":41,"tag":377,"props":1742,"children":1743},{},[1744],{"type":47,"value":1745},"        defines: {\n",{"type":41,"tag":377,"props":1747,"children":1749},{"class":802,"line":1748},12,[1750],{"type":41,"tag":377,"props":1751,"children":1752},{},[1753],{"type":47,"value":1754},"          if (input.config.code.targetOS == OS.windows)\n",{"type":41,"tag":377,"props":1756,"children":1758},{"class":802,"line":1757},13,[1759],{"type":41,"tag":377,"props":1760,"children":1761},{},[1762],{"type":47,"value":1763},"            \u002F\u002F Ensure C functions are explicitly exported in the Windows DLL\n",{"type":41,"tag":377,"props":1765,"children":1767},{"class":802,"line":1766},14,[1768],{"type":41,"tag":377,"props":1769,"children":1770},{},[1771],{"type":47,"value":1772},"            'SQLITE_API': '__declspec(dllexport)',\n",{"type":41,"tag":377,"props":1774,"children":1776},{"class":802,"line":1775},15,[1777],{"type":41,"tag":377,"props":1778,"children":1779},{},[1780],{"type":47,"value":1781},"        },\n",{"type":41,"tag":377,"props":1783,"children":1785},{"class":802,"line":1784},16,[1786],{"type":41,"tag":377,"props":1787,"children":1788},{},[1789],{"type":47,"value":1790},"      );\n",{"type":41,"tag":377,"props":1792,"children":1794},{"class":802,"line":1793},17,[1795],{"type":41,"tag":377,"props":1796,"children":1797},{},[1798],{"type":47,"value":1799},"    }\n",{"type":41,"tag":377,"props":1801,"children":1803},{"class":802,"line":1802},18,[1804],{"type":41,"tag":377,"props":1805,"children":1806},{},[1807],{"type":47,"value":1808},"  });\n",{"type":41,"tag":377,"props":1810,"children":1812},{"class":802,"line":1811},19,[1813],{"type":41,"tag":377,"props":1814,"children":1815},{},[1816],{"type":47,"value":1817},"}\n",{"type":41,"tag":766,"props":1819,"children":1821},{"id":1820},"implementing-hooklinkdart",[1822,1823],{"type":47,"value":1601},{"type":41,"tag":290,"props":1824,"children":1826},{"className":1825},[],[1827],{"type":47,"value":358},{"type":41,"tag":50,"props":1829,"children":1830},{},[1831,1833,1838,1840,1845],{"type":47,"value":1832},"Implement the link optimization phase in ",{"type":41,"tag":290,"props":1834,"children":1836},{"className":1835},[],[1837],{"type":47,"value":358},{"type":47,"value":1839},". This utilizes compiler tree-shaking options (",{"type":41,"tag":290,"props":1841,"children":1843},{"className":1842},[],[1844],{"type":47,"value":720},{"type":47,"value":1846},") to compile a minimized, dead-code-eliminated binary based on symbol usage records:",{"type":41,"tag":790,"props":1848,"children":1850},{"className":1457,"code":1849,"language":21,"meta":795,"style":795},"import 'package:hooks\u002Fhooks.dart';\nimport 'package:native_toolchain_c\u002Fnative_toolchain_c.dart';\nimport 'package:record_use\u002Frecord_use.dart';\nimport 'package:sqlite\u002Fsrc\u002Fc_library.dart';\nimport 'package:sqlite\u002Fsrc\u002Fthird_party\u002Fsqlite3.record_use_mapping.g.dart';\n\nvoid main(List\u003CString> arguments) async {\n  await link(arguments, (input, output) async {\n    await cLibrary.link(\n      input: input,\n      output: output,\n      linkerOptions: LinkerOptions.treeshake(\n        \u002F\u002F Map Dart Method references back to raw C symbol names\n        symbolsToKeep: input.recordedUses?.calls.keys.cast\u003CMethod>().map(\n          (e) => recordUseMapping[e.name]!,\n        ),\n      ),\n    );\n  });\n}\n",[1851],{"type":41,"tag":290,"props":1852,"children":1853},{"__ignoreMap":795},[1854,1861,1868,1876,1883,1891,1898,1906,1914,1922,1930,1938,1946,1954,1962,1970,1978,1986,1994,2001],{"type":41,"tag":377,"props":1855,"children":1856},{"class":802,"line":803},[1857],{"type":41,"tag":377,"props":1858,"children":1859},{},[1860],{"type":47,"value":1671},{"type":41,"tag":377,"props":1862,"children":1863},{"class":802,"line":885},[1864],{"type":41,"tag":377,"props":1865,"children":1866},{},[1867],{"type":47,"value":1540},{"type":41,"tag":377,"props":1869,"children":1870},{"class":802,"line":903},[1871],{"type":41,"tag":377,"props":1872,"children":1873},{},[1874],{"type":47,"value":1875},"import 'package:record_use\u002Frecord_use.dart';\n",{"type":41,"tag":377,"props":1877,"children":1878},{"class":802,"line":921},[1879],{"type":41,"tag":377,"props":1880,"children":1881},{},[1882],{"type":47,"value":1679},{"type":41,"tag":377,"props":1884,"children":1885},{"class":802,"line":938},[1886],{"type":41,"tag":377,"props":1887,"children":1888},{},[1889],{"type":47,"value":1890},"import 'package:sqlite\u002Fsrc\u002Fthird_party\u002Fsqlite3.record_use_mapping.g.dart';\n",{"type":41,"tag":377,"props":1892,"children":1893},{"class":802,"line":956},[1894],{"type":41,"tag":377,"props":1895,"children":1896},{"emptyLinePlaceholder":960},[1897],{"type":47,"value":963},{"type":41,"tag":377,"props":1899,"children":1900},{"class":802,"line":966},[1901],{"type":41,"tag":377,"props":1902,"children":1903},{},[1904],{"type":47,"value":1905},"void main(List\u003CString> arguments) async {\n",{"type":41,"tag":377,"props":1907,"children":1908},{"class":802,"line":979},[1909],{"type":41,"tag":377,"props":1910,"children":1911},{},[1912],{"type":47,"value":1913},"  await link(arguments, (input, output) async {\n",{"type":41,"tag":377,"props":1915,"children":1916},{"class":802,"line":1721},[1917],{"type":41,"tag":377,"props":1918,"children":1919},{},[1920],{"type":47,"value":1921},"    await cLibrary.link(\n",{"type":41,"tag":377,"props":1923,"children":1924},{"class":802,"line":1730},[1925],{"type":41,"tag":377,"props":1926,"children":1927},{},[1928],{"type":47,"value":1929},"      input: input,\n",{"type":41,"tag":377,"props":1931,"children":1932},{"class":802,"line":1739},[1933],{"type":41,"tag":377,"props":1934,"children":1935},{},[1936],{"type":47,"value":1937},"      output: output,\n",{"type":41,"tag":377,"props":1939,"children":1940},{"class":802,"line":1748},[1941],{"type":41,"tag":377,"props":1942,"children":1943},{},[1944],{"type":47,"value":1945},"      linkerOptions: LinkerOptions.treeshake(\n",{"type":41,"tag":377,"props":1947,"children":1948},{"class":802,"line":1757},[1949],{"type":41,"tag":377,"props":1950,"children":1951},{},[1952],{"type":47,"value":1953},"        \u002F\u002F Map Dart Method references back to raw C symbol names\n",{"type":41,"tag":377,"props":1955,"children":1956},{"class":802,"line":1766},[1957],{"type":41,"tag":377,"props":1958,"children":1959},{},[1960],{"type":47,"value":1961},"        symbolsToKeep: input.recordedUses?.calls.keys.cast\u003CMethod>().map(\n",{"type":41,"tag":377,"props":1963,"children":1964},{"class":802,"line":1775},[1965],{"type":41,"tag":377,"props":1966,"children":1967},{},[1968],{"type":47,"value":1969},"          (e) => recordUseMapping[e.name]!,\n",{"type":41,"tag":377,"props":1971,"children":1972},{"class":802,"line":1784},[1973],{"type":41,"tag":377,"props":1974,"children":1975},{},[1976],{"type":47,"value":1977},"        ),\n",{"type":41,"tag":377,"props":1979,"children":1980},{"class":802,"line":1793},[1981],{"type":41,"tag":377,"props":1982,"children":1983},{},[1984],{"type":47,"value":1985},"      ),\n",{"type":41,"tag":377,"props":1987,"children":1988},{"class":802,"line":1802},[1989],{"type":41,"tag":377,"props":1990,"children":1991},{},[1992],{"type":47,"value":1993},"    );\n",{"type":41,"tag":377,"props":1995,"children":1996},{"class":802,"line":1811},[1997],{"type":41,"tag":377,"props":1998,"children":1999},{},[2000],{"type":47,"value":1808},{"type":41,"tag":377,"props":2002,"children":2004},{"class":802,"line":2003},20,[2005],{"type":41,"tag":377,"props":2006,"children":2007},{},[2008],{"type":47,"value":1817},{"type":41,"tag":264,"props":2010,"children":2011},{},[],{"type":41,"tag":71,"props":2013,"children":2015},{"id":2014},"method-2-downloading-precompiled-dynamic-libraries",[2016],{"type":47,"value":193},{"type":41,"tag":50,"props":2018,"children":2019},{},[2020,2022,2028],{"type":47,"value":2021},"An alternative approach compiles binaries beforehand on a central build machine, archives them, and downloads the target binary during the build hook execution. This matches the paradigm demonstrated in the ",{"type":41,"tag":290,"props":2023,"children":2025},{"className":2024},[],[2026],{"type":47,"value":2027},"download_asset",{"type":47,"value":2029}," hook package.",{"type":41,"tag":766,"props":2031,"children":2033},{"id":2032},"why-download-precompiled-binaries",[2034],{"type":47,"value":205},{"type":41,"tag":78,"props":2036,"children":2037},{},[2038,2048,2058],{"type":41,"tag":82,"props":2039,"children":2040},{},[2041,2046],{"type":41,"tag":56,"props":2042,"children":2043},{},[2044],{"type":47,"value":2045},"Host Constraints",{"type":47,"value":2047},": Compiling large C\u002FC++ libraries locally requires a complete compiler setup (GCC, Xcode\u002FSDKs, Visual Studio) that the end-developer's host machine may not possess.",{"type":41,"tag":82,"props":2049,"children":2050},{},[2051,2056],{"type":41,"tag":56,"props":2052,"children":2053},{},[2054],{"type":47,"value":2055},"Compile Speed",{"type":47,"value":2057},": Precompiled downloads execute in milliseconds compared to potentially long multi-minute compilation processes.",{"type":41,"tag":82,"props":2059,"children":2060},{},[2061,2066],{"type":41,"tag":56,"props":2062,"children":2063},{},[2064],{"type":47,"value":2065},"Platform Bridging",{"type":47,"value":2067},": Allows cross-compiling constraints to be avoided if host architectures are limited.",{"type":41,"tag":264,"props":2069,"children":2070},{},[],{"type":41,"tag":766,"props":2072,"children":2074},{"id":2073},"implementing-precompiled-dynamic-downloads",[2075],{"type":47,"value":214},{"type":41,"tag":50,"props":2077,"children":2078},{},[2079,2081,2086,2088,2094,2096,2101],{"type":47,"value":2080},"We configure our build hook to detect local compiler flags (e.g. ",{"type":41,"tag":290,"props":2082,"children":2084},{"className":2083},[],[2085],{"type":47,"value":590},{"type":47,"value":2087},"). If not specified, the hook utilizes ",{"type":41,"tag":290,"props":2089,"children":2091},{"className":2090},[],[2092],{"type":47,"value":2093},"HttpClient",{"type":47,"value":2095}," to pull down platform-specific libraries, calculates the MD5 hash to confirm download safety against a configured hashes lookup table, and registers the binary file as a ",{"type":41,"tag":290,"props":2097,"children":2099},{"className":2098},[],[2100],{"type":47,"value":749},{"type":47,"value":858},{"type":41,"tag":2103,"props":2104,"children":2106},"h4",{"id":2105},"_1-defining-target-hashes-libsrchook_helpershashesdart",[2107,2109,2115],{"type":47,"value":2108},"1. Defining Target Hashes (",{"type":41,"tag":290,"props":2110,"children":2112},{"className":2111},[],[2113],{"type":47,"value":2114},"lib\u002Fsrc\u002Fhook_helpers\u002Fhashes.dart",{"type":47,"value":2116},")",{"type":41,"tag":50,"props":2118,"children":2119},{},[2120],{"type":47,"value":2121},"Define target MD5 hash checks per platform file in your package sources:",{"type":41,"tag":790,"props":2123,"children":2125},{"className":1457,"code":2124,"language":21,"meta":795,"style":795},"const assetHashes = {\n  'libnative_add_macos_arm64.dylib': '4a88f50438a98402db2dbd47b59eb412',\n  'libnative_add_linux_x64.so': '9f5e15043aa98402dcdbbd47b59ea520',\n  'native_add_windows_x64.dll': 'a881e5043ba98402acdebd47b59fa321',\n};\n",[2126],{"type":41,"tag":290,"props":2127,"children":2128},{"__ignoreMap":795},[2129,2137,2145,2153,2161],{"type":41,"tag":377,"props":2130,"children":2131},{"class":802,"line":803},[2132],{"type":41,"tag":377,"props":2133,"children":2134},{},[2135],{"type":47,"value":2136},"const assetHashes = {\n",{"type":41,"tag":377,"props":2138,"children":2139},{"class":802,"line":885},[2140],{"type":41,"tag":377,"props":2141,"children":2142},{},[2143],{"type":47,"value":2144},"  'libnative_add_macos_arm64.dylib': '4a88f50438a98402db2dbd47b59eb412',\n",{"type":41,"tag":377,"props":2146,"children":2147},{"class":802,"line":903},[2148],{"type":41,"tag":377,"props":2149,"children":2150},{},[2151],{"type":47,"value":2152},"  'libnative_add_linux_x64.so': '9f5e15043aa98402dcdbbd47b59ea520',\n",{"type":41,"tag":377,"props":2154,"children":2155},{"class":802,"line":921},[2156],{"type":41,"tag":377,"props":2157,"children":2158},{},[2159],{"type":47,"value":2160},"  'native_add_windows_x64.dll': 'a881e5043ba98402acdebd47b59fa321',\n",{"type":41,"tag":377,"props":2162,"children":2163},{"class":802,"line":938},[2164],{"type":41,"tag":377,"props":2165,"children":2166},{},[2167],{"type":47,"value":1509},{"type":41,"tag":2103,"props":2169,"children":2171},{"id":2170},"_2-hook-downloader-helper-libsrchook_helpersdownloaddart",[2172,2174,2180],{"type":47,"value":2173},"2. Hook Downloader Helper (",{"type":41,"tag":290,"props":2175,"children":2177},{"className":2176},[],[2178],{"type":47,"value":2179},"lib\u002Fsrc\u002Fhook_helpers\u002Fdownload.dart",{"type":47,"value":2116},{"type":41,"tag":50,"props":2182,"children":2183},{},[2184],{"type":47,"value":2185},"Implement the downloading and integrity check logic using dynamic target filename matching:",{"type":41,"tag":790,"props":2187,"children":2189},{"className":1457,"code":2188,"language":21,"meta":795,"style":795},"import 'dart:io';\nimport 'package:code_assets\u002Fcode_assets.dart';\nimport 'package:crypto\u002Fcrypto.dart';\n\nconst version = '1.0.0';\n\nUri downloadUri(String target) => Uri.parse(\n  'https:\u002F\u002Fgithub.com\u002Fmy-org\u002Fmy-native-repo\u002Freleases\u002Fdownload\u002F$version\u002F$target',\n);\n\nFuture\u003CFile> downloadAsset(\n  OS targetOS,\n  Architecture targetArchitecture,\n  Directory outputDir,\n) async {\n  final fileName = targetOS.dylibFileName('native_add_${targetOS.name}_${targetArchitecture.name}');\n  final uri = downloadUri(fileName);\n  \n  final client = HttpClient()..findProxy = HttpClient.findProxyFromEnvironment;\n  final request = await client.getUrl(uri);\n  final response = await request.close();\n  \n  if (response.statusCode != 200) {\n    throw ArgumentError('Download target $uri failed: Code ${response.statusCode}');\n  }\n  \n  final targetFile = File.fromUri(outputDir.uri.resolve(fileName));\n  await targetFile.create(recursive: true);\n  await response.pipe(targetFile.openWrite());\n  \n  return targetFile;\n}\n\nFuture\u003CString> hashAsset(File file) async {\n  return md5.convert(await file.readAsBytes()).toString();\n}\n",[2190],{"type":41,"tag":290,"props":2191,"children":2192},{"__ignoreMap":795},[2193,2201,2208,2216,2223,2231,2238,2246,2254,2261,2268,2276,2284,2292,2300,2308,2316,2324,2332,2340,2348,2357,2365,2374,2383,2392,2400,2409,2418,2427,2435,2444,2452,2460,2469,2478],{"type":41,"tag":377,"props":2194,"children":2195},{"class":802,"line":803},[2196],{"type":41,"tag":377,"props":2197,"children":2198},{},[2199],{"type":47,"value":2200},"import 'dart:io';\n",{"type":41,"tag":377,"props":2202,"children":2203},{"class":802,"line":885},[2204],{"type":41,"tag":377,"props":2205,"children":2206},{},[2207],{"type":47,"value":1663},{"type":41,"tag":377,"props":2209,"children":2210},{"class":802,"line":903},[2211],{"type":41,"tag":377,"props":2212,"children":2213},{},[2214],{"type":47,"value":2215},"import 'package:crypto\u002Fcrypto.dart';\n",{"type":41,"tag":377,"props":2217,"children":2218},{"class":802,"line":921},[2219],{"type":41,"tag":377,"props":2220,"children":2221},{"emptyLinePlaceholder":960},[2222],{"type":47,"value":963},{"type":41,"tag":377,"props":2224,"children":2225},{"class":802,"line":938},[2226],{"type":41,"tag":377,"props":2227,"children":2228},{},[2229],{"type":47,"value":2230},"const version = '1.0.0';\n",{"type":41,"tag":377,"props":2232,"children":2233},{"class":802,"line":956},[2234],{"type":41,"tag":377,"props":2235,"children":2236},{"emptyLinePlaceholder":960},[2237],{"type":47,"value":963},{"type":41,"tag":377,"props":2239,"children":2240},{"class":802,"line":966},[2241],{"type":41,"tag":377,"props":2242,"children":2243},{},[2244],{"type":47,"value":2245},"Uri downloadUri(String target) => Uri.parse(\n",{"type":41,"tag":377,"props":2247,"children":2248},{"class":802,"line":979},[2249],{"type":41,"tag":377,"props":2250,"children":2251},{},[2252],{"type":47,"value":2253},"  'https:\u002F\u002Fgithub.com\u002Fmy-org\u002Fmy-native-repo\u002Freleases\u002Fdownload\u002F$version\u002F$target',\n",{"type":41,"tag":377,"props":2255,"children":2256},{"class":802,"line":1721},[2257],{"type":41,"tag":377,"props":2258,"children":2259},{},[2260],{"type":47,"value":1595},{"type":41,"tag":377,"props":2262,"children":2263},{"class":802,"line":1730},[2264],{"type":41,"tag":377,"props":2265,"children":2266},{"emptyLinePlaceholder":960},[2267],{"type":47,"value":963},{"type":41,"tag":377,"props":2269,"children":2270},{"class":802,"line":1739},[2271],{"type":41,"tag":377,"props":2272,"children":2273},{},[2274],{"type":47,"value":2275},"Future\u003CFile> downloadAsset(\n",{"type":41,"tag":377,"props":2277,"children":2278},{"class":802,"line":1748},[2279],{"type":41,"tag":377,"props":2280,"children":2281},{},[2282],{"type":47,"value":2283},"  OS targetOS,\n",{"type":41,"tag":377,"props":2285,"children":2286},{"class":802,"line":1757},[2287],{"type":41,"tag":377,"props":2288,"children":2289},{},[2290],{"type":47,"value":2291},"  Architecture targetArchitecture,\n",{"type":41,"tag":377,"props":2293,"children":2294},{"class":802,"line":1766},[2295],{"type":41,"tag":377,"props":2296,"children":2297},{},[2298],{"type":47,"value":2299},"  Directory outputDir,\n",{"type":41,"tag":377,"props":2301,"children":2302},{"class":802,"line":1775},[2303],{"type":41,"tag":377,"props":2304,"children":2305},{},[2306],{"type":47,"value":2307},") async {\n",{"type":41,"tag":377,"props":2309,"children":2310},{"class":802,"line":1784},[2311],{"type":41,"tag":377,"props":2312,"children":2313},{},[2314],{"type":47,"value":2315},"  final fileName = targetOS.dylibFileName('native_add_${targetOS.name}_${targetArchitecture.name}');\n",{"type":41,"tag":377,"props":2317,"children":2318},{"class":802,"line":1793},[2319],{"type":41,"tag":377,"props":2320,"children":2321},{},[2322],{"type":47,"value":2323},"  final uri = downloadUri(fileName);\n",{"type":41,"tag":377,"props":2325,"children":2326},{"class":802,"line":1802},[2327],{"type":41,"tag":377,"props":2328,"children":2329},{},[2330],{"type":47,"value":2331},"  \n",{"type":41,"tag":377,"props":2333,"children":2334},{"class":802,"line":1811},[2335],{"type":41,"tag":377,"props":2336,"children":2337},{},[2338],{"type":47,"value":2339},"  final client = HttpClient()..findProxy = HttpClient.findProxyFromEnvironment;\n",{"type":41,"tag":377,"props":2341,"children":2342},{"class":802,"line":2003},[2343],{"type":41,"tag":377,"props":2344,"children":2345},{},[2346],{"type":47,"value":2347},"  final request = await client.getUrl(uri);\n",{"type":41,"tag":377,"props":2349,"children":2351},{"class":802,"line":2350},21,[2352],{"type":41,"tag":377,"props":2353,"children":2354},{},[2355],{"type":47,"value":2356},"  final response = await request.close();\n",{"type":41,"tag":377,"props":2358,"children":2360},{"class":802,"line":2359},22,[2361],{"type":41,"tag":377,"props":2362,"children":2363},{},[2364],{"type":47,"value":2331},{"type":41,"tag":377,"props":2366,"children":2368},{"class":802,"line":2367},23,[2369],{"type":41,"tag":377,"props":2370,"children":2371},{},[2372],{"type":47,"value":2373},"  if (response.statusCode != 200) {\n",{"type":41,"tag":377,"props":2375,"children":2377},{"class":802,"line":2376},24,[2378],{"type":41,"tag":377,"props":2379,"children":2380},{},[2381],{"type":47,"value":2382},"    throw ArgumentError('Download target $uri failed: Code ${response.statusCode}');\n",{"type":41,"tag":377,"props":2384,"children":2386},{"class":802,"line":2385},25,[2387],{"type":41,"tag":377,"props":2388,"children":2389},{},[2390],{"type":47,"value":2391},"  }\n",{"type":41,"tag":377,"props":2393,"children":2395},{"class":802,"line":2394},26,[2396],{"type":41,"tag":377,"props":2397,"children":2398},{},[2399],{"type":47,"value":2331},{"type":41,"tag":377,"props":2401,"children":2403},{"class":802,"line":2402},27,[2404],{"type":41,"tag":377,"props":2405,"children":2406},{},[2407],{"type":47,"value":2408},"  final targetFile = File.fromUri(outputDir.uri.resolve(fileName));\n",{"type":41,"tag":377,"props":2410,"children":2412},{"class":802,"line":2411},28,[2413],{"type":41,"tag":377,"props":2414,"children":2415},{},[2416],{"type":47,"value":2417},"  await targetFile.create(recursive: true);\n",{"type":41,"tag":377,"props":2419,"children":2421},{"class":802,"line":2420},29,[2422],{"type":41,"tag":377,"props":2423,"children":2424},{},[2425],{"type":47,"value":2426},"  await response.pipe(targetFile.openWrite());\n",{"type":41,"tag":377,"props":2428,"children":2430},{"class":802,"line":2429},30,[2431],{"type":41,"tag":377,"props":2432,"children":2433},{},[2434],{"type":47,"value":2331},{"type":41,"tag":377,"props":2436,"children":2438},{"class":802,"line":2437},31,[2439],{"type":41,"tag":377,"props":2440,"children":2441},{},[2442],{"type":47,"value":2443},"  return targetFile;\n",{"type":41,"tag":377,"props":2445,"children":2447},{"class":802,"line":2446},32,[2448],{"type":41,"tag":377,"props":2449,"children":2450},{},[2451],{"type":47,"value":1817},{"type":41,"tag":377,"props":2453,"children":2455},{"class":802,"line":2454},33,[2456],{"type":41,"tag":377,"props":2457,"children":2458},{"emptyLinePlaceholder":960},[2459],{"type":47,"value":963},{"type":41,"tag":377,"props":2461,"children":2463},{"class":802,"line":2462},34,[2464],{"type":41,"tag":377,"props":2465,"children":2466},{},[2467],{"type":47,"value":2468},"Future\u003CString> hashAsset(File file) async {\n",{"type":41,"tag":377,"props":2470,"children":2472},{"class":802,"line":2471},35,[2473],{"type":41,"tag":377,"props":2474,"children":2475},{},[2476],{"type":47,"value":2477},"  return md5.convert(await file.readAsBytes()).toString();\n",{"type":41,"tag":377,"props":2479,"children":2481},{"class":802,"line":2480},36,[2482],{"type":41,"tag":377,"props":2483,"children":2484},{},[2485],{"type":47,"value":1817},{"type":41,"tag":2103,"props":2487,"children":2489},{"id":2488},"_3-implementing-hookbuilddart",[2490,2492],{"type":47,"value":2491},"3. Implementing ",{"type":41,"tag":290,"props":2493,"children":2495},{"className":2494},[],[2496],{"type":47,"value":347},{"type":41,"tag":50,"props":2498,"children":2499},{},[2500],{"type":47,"value":2501},"Write the final download build hook incorporating local compilation fallback:",{"type":41,"tag":790,"props":2503,"children":2505},{"className":1457,"code":2504,"language":21,"meta":795,"style":795},"import 'dart:io';\nimport 'package:code_assets\u002Fcode_assets.dart';\nimport 'package:hooks\u002Fhooks.dart';\nimport 'package:my_download_package\u002Fsrc\u002Fhook_helpers\u002Fhashes.dart';\nimport 'package:my_download_package\u002Fsrc\u002Fhook_helpers\u002Fdownload.dart';\nimport 'package:native_toolchain_c\u002Fnative_toolchain_c.dart';\n\nvoid main(List\u003CString> args) async {\n  await build(args, (input, output) async {\n    final localBuild = input.userDefines['local_build'] as bool? ?? false;\n\n    if (localBuild) {\n      final name = 'native_add_${input.config.code.targetOS.name}_${input.config.code.targetArchitecture.name}';\n      final builder = CBuilder.library(\n        name: name,\n        assetName: 'native_add.dart',\n        sources: ['src\u002Fnative_add.c'],\n      );\n      await builder.run(input: input, output: output);\n    } else {\n      final targetOS = input.config.code.targetOS;\n      final targetArch = input.config.code.targetArchitecture;\n      final outputDir = Directory.fromUri(input.outputDirectory);\n\n      final file = await downloadAsset(targetOS, targetArch, outputDir);\n\n      final fileHash = await hashAsset(file);\n      final expectedFileName = targetOS.dylibFileName('native_add_${targetOS.name}_${targetArch.name}');\n      final expectedHash = assetHashes[expectedFileName];\n\n      if (fileHash != expectedHash) {\n        throw Exception(\n          'Security Mismatch: File $expectedFileName hash verification failed! '\n          'Found hash: $fileHash, expected: $expectedHash.'\n        );\n      }\n\n      output.assets.code.add(\n        CodeAsset(\n          package: input.packageName,\n          name: 'native_add.dart',\n          linkMode: DynamicLoadingBundled(),\n          file: file.uri,\n        ),\n      );\n    }\n  });\n}\n",[2506],{"type":41,"tag":290,"props":2507,"children":2508},{"__ignoreMap":795},[2509,2516,2523,2530,2538,2546,2553,2560,2567,2574,2582,2589,2597,2605,2613,2621,2629,2637,2644,2652,2660,2668,2676,2684,2691,2699,2706,2714,2722,2730,2737,2745,2753,2761,2769,2777,2785,2793,2802,2811,2820,2829,2838,2847,2855,2863,2871,2879],{"type":41,"tag":377,"props":2510,"children":2511},{"class":802,"line":803},[2512],{"type":41,"tag":377,"props":2513,"children":2514},{},[2515],{"type":47,"value":2200},{"type":41,"tag":377,"props":2517,"children":2518},{"class":802,"line":885},[2519],{"type":41,"tag":377,"props":2520,"children":2521},{},[2522],{"type":47,"value":1663},{"type":41,"tag":377,"props":2524,"children":2525},{"class":802,"line":903},[2526],{"type":41,"tag":377,"props":2527,"children":2528},{},[2529],{"type":47,"value":1671},{"type":41,"tag":377,"props":2531,"children":2532},{"class":802,"line":921},[2533],{"type":41,"tag":377,"props":2534,"children":2535},{},[2536],{"type":47,"value":2537},"import 'package:my_download_package\u002Fsrc\u002Fhook_helpers\u002Fhashes.dart';\n",{"type":41,"tag":377,"props":2539,"children":2540},{"class":802,"line":938},[2541],{"type":41,"tag":377,"props":2542,"children":2543},{},[2544],{"type":47,"value":2545},"import 'package:my_download_package\u002Fsrc\u002Fhook_helpers\u002Fdownload.dart';\n",{"type":41,"tag":377,"props":2547,"children":2548},{"class":802,"line":956},[2549],{"type":41,"tag":377,"props":2550,"children":2551},{},[2552],{"type":47,"value":1540},{"type":41,"tag":377,"props":2554,"children":2555},{"class":802,"line":966},[2556],{"type":41,"tag":377,"props":2557,"children":2558},{"emptyLinePlaceholder":960},[2559],{"type":47,"value":963},{"type":41,"tag":377,"props":2561,"children":2562},{"class":802,"line":979},[2563],{"type":41,"tag":377,"props":2564,"children":2565},{},[2566],{"type":47,"value":1694},{"type":41,"tag":377,"props":2568,"children":2569},{"class":802,"line":1721},[2570],{"type":41,"tag":377,"props":2571,"children":2572},{},[2573],{"type":47,"value":1702},{"type":41,"tag":377,"props":2575,"children":2576},{"class":802,"line":1730},[2577],{"type":41,"tag":377,"props":2578,"children":2579},{},[2580],{"type":47,"value":2581},"    final localBuild = input.userDefines['local_build'] as bool? ?? false;\n",{"type":41,"tag":377,"props":2583,"children":2584},{"class":802,"line":1739},[2585],{"type":41,"tag":377,"props":2586,"children":2587},{"emptyLinePlaceholder":960},[2588],{"type":47,"value":963},{"type":41,"tag":377,"props":2590,"children":2591},{"class":802,"line":1748},[2592],{"type":41,"tag":377,"props":2593,"children":2594},{},[2595],{"type":47,"value":2596},"    if (localBuild) {\n",{"type":41,"tag":377,"props":2598,"children":2599},{"class":802,"line":1757},[2600],{"type":41,"tag":377,"props":2601,"children":2602},{},[2603],{"type":47,"value":2604},"      final name = 'native_add_${input.config.code.targetOS.name}_${input.config.code.targetArchitecture.name}';\n",{"type":41,"tag":377,"props":2606,"children":2607},{"class":802,"line":1766},[2608],{"type":41,"tag":377,"props":2609,"children":2610},{},[2611],{"type":47,"value":2612},"      final builder = CBuilder.library(\n",{"type":41,"tag":377,"props":2614,"children":2615},{"class":802,"line":1775},[2616],{"type":41,"tag":377,"props":2617,"children":2618},{},[2619],{"type":47,"value":2620},"        name: name,\n",{"type":41,"tag":377,"props":2622,"children":2623},{"class":802,"line":1784},[2624],{"type":41,"tag":377,"props":2625,"children":2626},{},[2627],{"type":47,"value":2628},"        assetName: 'native_add.dart',\n",{"type":41,"tag":377,"props":2630,"children":2631},{"class":802,"line":1793},[2632],{"type":41,"tag":377,"props":2633,"children":2634},{},[2635],{"type":47,"value":2636},"        sources: ['src\u002Fnative_add.c'],\n",{"type":41,"tag":377,"props":2638,"children":2639},{"class":802,"line":1802},[2640],{"type":41,"tag":377,"props":2641,"children":2642},{},[2643],{"type":47,"value":1790},{"type":41,"tag":377,"props":2645,"children":2646},{"class":802,"line":1811},[2647],{"type":41,"tag":377,"props":2648,"children":2649},{},[2650],{"type":47,"value":2651},"      await builder.run(input: input, output: output);\n",{"type":41,"tag":377,"props":2653,"children":2654},{"class":802,"line":2003},[2655],{"type":41,"tag":377,"props":2656,"children":2657},{},[2658],{"type":47,"value":2659},"    } else {\n",{"type":41,"tag":377,"props":2661,"children":2662},{"class":802,"line":2350},[2663],{"type":41,"tag":377,"props":2664,"children":2665},{},[2666],{"type":47,"value":2667},"      final targetOS = input.config.code.targetOS;\n",{"type":41,"tag":377,"props":2669,"children":2670},{"class":802,"line":2359},[2671],{"type":41,"tag":377,"props":2672,"children":2673},{},[2674],{"type":47,"value":2675},"      final targetArch = input.config.code.targetArchitecture;\n",{"type":41,"tag":377,"props":2677,"children":2678},{"class":802,"line":2367},[2679],{"type":41,"tag":377,"props":2680,"children":2681},{},[2682],{"type":47,"value":2683},"      final outputDir = Directory.fromUri(input.outputDirectory);\n",{"type":41,"tag":377,"props":2685,"children":2686},{"class":802,"line":2376},[2687],{"type":41,"tag":377,"props":2688,"children":2689},{"emptyLinePlaceholder":960},[2690],{"type":47,"value":963},{"type":41,"tag":377,"props":2692,"children":2693},{"class":802,"line":2385},[2694],{"type":41,"tag":377,"props":2695,"children":2696},{},[2697],{"type":47,"value":2698},"      final file = await downloadAsset(targetOS, targetArch, outputDir);\n",{"type":41,"tag":377,"props":2700,"children":2701},{"class":802,"line":2394},[2702],{"type":41,"tag":377,"props":2703,"children":2704},{"emptyLinePlaceholder":960},[2705],{"type":47,"value":963},{"type":41,"tag":377,"props":2707,"children":2708},{"class":802,"line":2402},[2709],{"type":41,"tag":377,"props":2710,"children":2711},{},[2712],{"type":47,"value":2713},"      final fileHash = await hashAsset(file);\n",{"type":41,"tag":377,"props":2715,"children":2716},{"class":802,"line":2411},[2717],{"type":41,"tag":377,"props":2718,"children":2719},{},[2720],{"type":47,"value":2721},"      final expectedFileName = targetOS.dylibFileName('native_add_${targetOS.name}_${targetArch.name}');\n",{"type":41,"tag":377,"props":2723,"children":2724},{"class":802,"line":2420},[2725],{"type":41,"tag":377,"props":2726,"children":2727},{},[2728],{"type":47,"value":2729},"      final expectedHash = assetHashes[expectedFileName];\n",{"type":41,"tag":377,"props":2731,"children":2732},{"class":802,"line":2429},[2733],{"type":41,"tag":377,"props":2734,"children":2735},{"emptyLinePlaceholder":960},[2736],{"type":47,"value":963},{"type":41,"tag":377,"props":2738,"children":2739},{"class":802,"line":2437},[2740],{"type":41,"tag":377,"props":2741,"children":2742},{},[2743],{"type":47,"value":2744},"      if (fileHash != expectedHash) {\n",{"type":41,"tag":377,"props":2746,"children":2747},{"class":802,"line":2446},[2748],{"type":41,"tag":377,"props":2749,"children":2750},{},[2751],{"type":47,"value":2752},"        throw Exception(\n",{"type":41,"tag":377,"props":2754,"children":2755},{"class":802,"line":2454},[2756],{"type":41,"tag":377,"props":2757,"children":2758},{},[2759],{"type":47,"value":2760},"          'Security Mismatch: File $expectedFileName hash verification failed! '\n",{"type":41,"tag":377,"props":2762,"children":2763},{"class":802,"line":2462},[2764],{"type":41,"tag":377,"props":2765,"children":2766},{},[2767],{"type":47,"value":2768},"          'Found hash: $fileHash, expected: $expectedHash.'\n",{"type":41,"tag":377,"props":2770,"children":2771},{"class":802,"line":2471},[2772],{"type":41,"tag":377,"props":2773,"children":2774},{},[2775],{"type":47,"value":2776},"        );\n",{"type":41,"tag":377,"props":2778,"children":2779},{"class":802,"line":2480},[2780],{"type":41,"tag":377,"props":2781,"children":2782},{},[2783],{"type":47,"value":2784},"      }\n",{"type":41,"tag":377,"props":2786,"children":2788},{"class":802,"line":2787},37,[2789],{"type":41,"tag":377,"props":2790,"children":2791},{"emptyLinePlaceholder":960},[2792],{"type":47,"value":963},{"type":41,"tag":377,"props":2794,"children":2796},{"class":802,"line":2795},38,[2797],{"type":41,"tag":377,"props":2798,"children":2799},{},[2800],{"type":47,"value":2801},"      output.assets.code.add(\n",{"type":41,"tag":377,"props":2803,"children":2805},{"class":802,"line":2804},39,[2806],{"type":41,"tag":377,"props":2807,"children":2808},{},[2809],{"type":47,"value":2810},"        CodeAsset(\n",{"type":41,"tag":377,"props":2812,"children":2814},{"class":802,"line":2813},40,[2815],{"type":41,"tag":377,"props":2816,"children":2817},{},[2818],{"type":47,"value":2819},"          package: input.packageName,\n",{"type":41,"tag":377,"props":2821,"children":2823},{"class":802,"line":2822},41,[2824],{"type":41,"tag":377,"props":2825,"children":2826},{},[2827],{"type":47,"value":2828},"          name: 'native_add.dart',\n",{"type":41,"tag":377,"props":2830,"children":2832},{"class":802,"line":2831},42,[2833],{"type":41,"tag":377,"props":2834,"children":2835},{},[2836],{"type":47,"value":2837},"          linkMode: DynamicLoadingBundled(),\n",{"type":41,"tag":377,"props":2839,"children":2841},{"class":802,"line":2840},43,[2842],{"type":41,"tag":377,"props":2843,"children":2844},{},[2845],{"type":47,"value":2846},"          file: file.uri,\n",{"type":41,"tag":377,"props":2848,"children":2850},{"class":802,"line":2849},44,[2851],{"type":41,"tag":377,"props":2852,"children":2853},{},[2854],{"type":47,"value":1977},{"type":41,"tag":377,"props":2856,"children":2858},{"class":802,"line":2857},45,[2859],{"type":41,"tag":377,"props":2860,"children":2861},{},[2862],{"type":47,"value":1790},{"type":41,"tag":377,"props":2864,"children":2866},{"class":802,"line":2865},46,[2867],{"type":41,"tag":377,"props":2868,"children":2869},{},[2870],{"type":47,"value":1799},{"type":41,"tag":377,"props":2872,"children":2874},{"class":802,"line":2873},47,[2875],{"type":41,"tag":377,"props":2876,"children":2877},{},[2878],{"type":47,"value":1808},{"type":41,"tag":377,"props":2880,"children":2882},{"class":802,"line":2881},48,[2883],{"type":41,"tag":377,"props":2884,"children":2885},{},[2886],{"type":47,"value":1817},{"type":41,"tag":264,"props":2888,"children":2889},{},[],{"type":41,"tag":71,"props":2891,"children":2893},{"id":2892},"verification-checklist",[2894],{"type":47,"value":223},{"type":41,"tag":50,"props":2896,"children":2897},{},[2898],{"type":47,"value":2899},"Before declaring a build or link hook implementation complete, always perform the following checks:",{"type":41,"tag":766,"props":2901,"children":2903},{"id":2902},"_1-local-execution-sandbox",[2904],{"type":47,"value":235},{"type":41,"tag":50,"props":2906,"children":2907},{},[2908],{"type":47,"value":2909},"Run unit tests and confirm the native assets compile\u002Flink process completes with no runtime or build tool exceptions:",{"type":41,"tag":790,"props":2911,"children":2912},{"className":792,"code":1051,"language":794,"meta":795,"style":795},[2913],{"type":41,"tag":290,"props":2914,"children":2915},{"__ignoreMap":795},[2916],{"type":41,"tag":377,"props":2917,"children":2918},{"class":802,"line":803},[2919,2923],{"type":41,"tag":377,"props":2920,"children":2921},{"style":807},[2922],{"type":47,"value":21},{"type":41,"tag":377,"props":2924,"children":2925},{"style":812},[2926],{"type":47,"value":1067},{"type":41,"tag":766,"props":2928,"children":2930},{"id":2929},"_2-verify-target-outputs",[2931],{"type":47,"value":244},{"type":41,"tag":50,"props":2933,"children":2934},{},[2935],{"type":47,"value":2936},"Navigate to your package target directory and verify that dynamic binary assets are created for the host system:",{"type":41,"tag":78,"props":2938,"children":2939},{},[2940,2964,2984],{"type":41,"tag":82,"props":2941,"children":2942},{},[2943,2947,2949,2955,2957,2962],{"type":41,"tag":56,"props":2944,"children":2945},{},[2946],{"type":47,"value":1246},{"type":47,"value":2948},": Verify ",{"type":41,"tag":290,"props":2950,"children":2952},{"className":2951},[],[2953],{"type":47,"value":2954},".dart_tool\u002Fresources\u002F",{"type":47,"value":2956}," or target directories contain ",{"type":41,"tag":290,"props":2958,"children":2960},{"className":2959},[],[2961],{"type":47,"value":1639},{"type":47,"value":2963}," files.",{"type":41,"tag":82,"props":2965,"children":2966},{},[2967,2971,2972,2977,2978,2983],{"type":41,"tag":56,"props":2968,"children":2969},{},[2970],{"type":47,"value":1276},{"type":47,"value":2948},{"type":41,"tag":290,"props":2973,"children":2975},{"className":2974},[],[2976],{"type":47,"value":2954},{"type":47,"value":2956},{"type":41,"tag":290,"props":2979,"children":2981},{"className":2980},[],[2982],{"type":47,"value":1632},{"type":47,"value":2963},{"type":41,"tag":82,"props":2985,"children":2986},{},[2987,2991,2992,2997,2998,3003],{"type":41,"tag":56,"props":2988,"children":2989},{},[2990],{"type":47,"value":1316},{"type":47,"value":2948},{"type":41,"tag":290,"props":2993,"children":2995},{"className":2994},[],[2996],{"type":47,"value":2954},{"type":47,"value":2956},{"type":41,"tag":290,"props":2999,"children":3001},{"className":3000},[],[3002],{"type":47,"value":1646},{"type":47,"value":2963},{"type":41,"tag":766,"props":3005,"children":3007},{"id":3006},"_3-verify-tree-shaking-stripping",[3008],{"type":47,"value":253},{"type":41,"tag":50,"props":3010,"children":3011},{},[3012],{"type":47,"value":3013},"To ensure the link hook is actually stripping unused native symbols and compressing binary packaging, perform the following validation:",{"type":41,"tag":336,"props":3015,"children":3016},{},[3017,3051,3056,3154,3179],{"type":41,"tag":82,"props":3018,"children":3019},{},[3020,3022],{"type":47,"value":3021},"Compile a production bundle of the CLI\u002Fapp:\n",{"type":41,"tag":790,"props":3023,"children":3025},{"className":792,"code":3024,"language":794,"meta":795,"style":795},"dart build cli bin\u002Fmain.dart\n",[3026],{"type":41,"tag":290,"props":3027,"children":3028},{"__ignoreMap":795},[3029],{"type":41,"tag":377,"props":3030,"children":3031},{"class":802,"line":803},[3032,3036,3041,3046],{"type":41,"tag":377,"props":3033,"children":3034},{"style":807},[3035],{"type":47,"value":21},{"type":41,"tag":377,"props":3037,"children":3038},{"style":812},[3039],{"type":47,"value":3040}," build",{"type":41,"tag":377,"props":3042,"children":3043},{"style":812},[3044],{"type":47,"value":3045}," cli",{"type":41,"tag":377,"props":3047,"children":3048},{"style":812},[3049],{"type":47,"value":3050}," bin\u002Fmain.dart\n",{"type":41,"tag":82,"props":3052,"children":3053},{},[3054],{"type":47,"value":3055},"Navigate to the compiled build directory containing the dynamic library.",{"type":41,"tag":82,"props":3057,"children":3058},{},[3059,3061],{"type":47,"value":3060},"Query the exported dynamic symbol tables:\n",{"type":41,"tag":78,"props":3062,"children":3063},{},[3064,3097,3129],{"type":41,"tag":82,"props":3065,"children":3066},{},[3067,3071,3072],{"type":41,"tag":56,"props":3068,"children":3069},{},[3070],{"type":47,"value":1246},{"type":47,"value":882},{"type":41,"tag":790,"props":3073,"children":3075},{"className":792,"code":3074,"language":794,"meta":795,"style":795},"nm -gU build\u002Fcli\u002Flib\u002Flibsqlite3.dylib\n",[3076],{"type":41,"tag":290,"props":3077,"children":3078},{"__ignoreMap":795},[3079],{"type":41,"tag":377,"props":3080,"children":3081},{"class":802,"line":803},[3082,3087,3092],{"type":41,"tag":377,"props":3083,"children":3084},{"style":807},[3085],{"type":47,"value":3086},"nm",{"type":41,"tag":377,"props":3088,"children":3089},{"style":812},[3090],{"type":47,"value":3091}," -gU",{"type":41,"tag":377,"props":3093,"children":3094},{"style":812},[3095],{"type":47,"value":3096}," build\u002Fcli\u002Flib\u002Flibsqlite3.dylib\n",{"type":41,"tag":82,"props":3098,"children":3099},{},[3100,3104,3105],{"type":41,"tag":56,"props":3101,"children":3102},{},[3103],{"type":47,"value":1276},{"type":47,"value":882},{"type":41,"tag":790,"props":3106,"children":3108},{"className":792,"code":3107,"language":794,"meta":795,"style":795},"nm -D build\u002Fcli\u002Flib\u002Flibsqlite3.so\n",[3109],{"type":41,"tag":290,"props":3110,"children":3111},{"__ignoreMap":795},[3112],{"type":41,"tag":377,"props":3113,"children":3114},{"class":802,"line":803},[3115,3119,3124],{"type":41,"tag":377,"props":3116,"children":3117},{"style":807},[3118],{"type":47,"value":3086},{"type":41,"tag":377,"props":3120,"children":3121},{"style":812},[3122],{"type":47,"value":3123}," -D",{"type":41,"tag":377,"props":3125,"children":3126},{"style":812},[3127],{"type":47,"value":3128}," build\u002Fcli\u002Flib\u002Flibsqlite3.so\n",{"type":41,"tag":82,"props":3130,"children":3131},{},[3132,3136,3138],{"type":41,"tag":56,"props":3133,"children":3134},{},[3135],{"type":47,"value":1316},{"type":47,"value":3137}," (using MSVC Developer Command Prompt):\n",{"type":41,"tag":790,"props":3139,"children":3143},{"className":3140,"code":3141,"language":3142,"meta":795,"style":795},"language-cmd shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","dumpbin \u002FEXPORTS build\\cli\\lib\\sqlite3.dll\n","cmd",[3144],{"type":41,"tag":290,"props":3145,"children":3146},{"__ignoreMap":795},[3147],{"type":41,"tag":377,"props":3148,"children":3149},{"class":802,"line":803},[3150],{"type":41,"tag":377,"props":3151,"children":3152},{},[3153],{"type":47,"value":3141},{"type":41,"tag":82,"props":3155,"children":3156},{},[3157,3162,3164,3169,3171,3177],{"type":41,"tag":56,"props":3158,"children":3159},{},[3160],{"type":47,"value":3161},"Confirm Target Exports",{"type":47,"value":3163},": Verify that the command outputs ",{"type":41,"tag":56,"props":3165,"children":3166},{},[3167],{"type":47,"value":3168},"only",{"type":47,"value":3170}," the explicitly kept entry point functions (e.g. ",{"type":41,"tag":290,"props":3172,"children":3174},{"className":3173},[],[3175],{"type":47,"value":3176},"sqlite3_libversion",{"type":47,"value":3178},") and does not output any unreferenced\u002Fstripped symbols.",{"type":41,"tag":82,"props":3180,"children":3181},{},[3182,3187,3189],{"type":41,"tag":56,"props":3183,"children":3184},{},[3185],{"type":47,"value":3186},"No Bundle Scenario",{"type":47,"value":3188},": If the application does not import or invoke any methods from the native library:\n",{"type":41,"tag":78,"props":3190,"children":3191},{},[3192,3203],{"type":41,"tag":82,"props":3193,"children":3194},{},[3195,3197],{"type":47,"value":3196},"Verify that the link hook logs: ",{"type":41,"tag":290,"props":3198,"children":3200},{"className":3199},[],[3201],{"type":47,"value":3202},"Skipping linking as no symbols are to be kept.",{"type":41,"tag":82,"props":3204,"children":3205},{},[3206,3208,3213,3215,3220,3221,3226],{"type":47,"value":3207},"Verify that no library was built\u002Fplaced in the production bundle (the ",{"type":41,"tag":290,"props":3209,"children":3211},{"className":3210},[],[3212],{"type":47,"value":1639},{"type":47,"value":3214},"\u002F",{"type":41,"tag":290,"props":3216,"children":3218},{"className":3217},[],[3219],{"type":47,"value":1632},{"type":47,"value":3214},{"type":41,"tag":290,"props":3222,"children":3224},{"className":3223},[],[3225],{"type":47,"value":1646},{"type":47,"value":3227}," file is not generated, saving bundle size).",{"type":41,"tag":766,"props":3229,"children":3231},{"id":3230},"_4-verify-offline-compliance-user-defines",[3232],{"type":47,"value":262},{"type":41,"tag":50,"props":3234,"children":3235},{},[3236],{"type":47,"value":3237},"Confirm offline compliance is fully active and the download fallback executes perfectly offline:",{"type":41,"tag":336,"props":3239,"children":3240},{},[3241,3329,3334,3356],{"type":41,"tag":82,"props":3242,"children":3243},{},[3244,3246,3252,3254,3259,3261,3266,3268],{"type":47,"value":3245},"Configure the ",{"type":41,"tag":290,"props":3247,"children":3249},{"className":3248},[],[3250],{"type":47,"value":3251},"local_build: true",{"type":47,"value":3253}," define for your package in the package's ",{"type":41,"tag":290,"props":3255,"children":3257},{"className":3256},[],[3258],{"type":47,"value":856},{"type":47,"value":3260}," (or the workspace root ",{"type":41,"tag":290,"props":3262,"children":3264},{"className":3263},[],[3265],{"type":47,"value":856},{"type":47,"value":3267},"):\n",{"type":41,"tag":790,"props":3269,"children":3271},{"className":861,"code":3270,"language":863,"meta":795,"style":795},"hooks:\n  user_defines:\n    \u003Cyour_package_name>:\n      local_build: true\n",[3272],{"type":41,"tag":290,"props":3273,"children":3274},{"__ignoreMap":795},[3275,3287,3299,3311],{"type":41,"tag":377,"props":3276,"children":3277},{"class":802,"line":803},[3278,3283],{"type":41,"tag":377,"props":3279,"children":3280},{"style":873},[3281],{"type":47,"value":3282},"hooks",{"type":41,"tag":377,"props":3284,"children":3285},{"style":879},[3286],{"type":47,"value":882},{"type":41,"tag":377,"props":3288,"children":3289},{"class":802,"line":885},[3290,3295],{"type":41,"tag":377,"props":3291,"children":3292},{"style":873},[3293],{"type":47,"value":3294},"  user_defines",{"type":41,"tag":377,"props":3296,"children":3297},{"style":879},[3298],{"type":47,"value":882},{"type":41,"tag":377,"props":3300,"children":3301},{"class":802,"line":903},[3302,3307],{"type":41,"tag":377,"props":3303,"children":3304},{"style":873},[3305],{"type":47,"value":3306},"    \u003Cyour_package_name>",{"type":41,"tag":377,"props":3308,"children":3309},{"style":879},[3310],{"type":47,"value":882},{"type":41,"tag":377,"props":3312,"children":3313},{"class":802,"line":921},[3314,3319,3323],{"type":41,"tag":377,"props":3315,"children":3316},{"style":873},[3317],{"type":47,"value":3318},"      local_build",{"type":41,"tag":377,"props":3320,"children":3321},{"style":879},[3322],{"type":47,"value":858},{"type":41,"tag":377,"props":3324,"children":3326},{"style":3325},"--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC",[3327],{"type":47,"value":3328}," true\n",{"type":41,"tag":82,"props":3330,"children":3331},{},[3332],{"type":47,"value":3333},"Disable the machine's network adapter or run in a sandboxed offline shell.",{"type":41,"tag":82,"props":3335,"children":3336},{},[3337,3339],{"type":47,"value":3338},"Launch unit tests:\n",{"type":41,"tag":790,"props":3340,"children":3341},{"className":792,"code":1051,"language":794,"meta":795,"style":795},[3342],{"type":41,"tag":290,"props":3343,"children":3344},{"__ignoreMap":795},[3345],{"type":41,"tag":377,"props":3346,"children":3347},{"class":802,"line":803},[3348,3352],{"type":41,"tag":377,"props":3349,"children":3350},{"style":807},[3351],{"type":47,"value":21},{"type":41,"tag":377,"props":3353,"children":3354},{"style":812},[3355],{"type":47,"value":1067},{"type":41,"tag":82,"props":3357,"children":3358},{},[3359],{"type":47,"value":3360},"Verify the test suite successfully compiles local source files using host compilers, has no compile errors, and never attempts network download requests.",{"type":41,"tag":3362,"props":3363,"children":3364},"style",{},[3365],{"type":47,"value":3366},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":3368,"total":2376},[3369,3380,3391,3403,3414,3423,3435],{"slug":3370,"name":3370,"fn":3371,"description":3372,"org":3373,"tags":3374,"stars":22,"repoUrl":23,"updatedAt":3379},"dart-add-unit-test","write unit tests for Dart code","Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains correct and regression-free.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3375,3376],{"name":20,"slug":21,"type":15},{"name":3377,"slug":3378,"type":15},"Testing","testing","2026-07-15T05:22:40.104823",{"slug":3381,"name":3381,"fn":3382,"description":3383,"org":3384,"tags":3385,"stars":22,"repoUrl":23,"updatedAt":3390},"dart-build-cli-app","build Dart command line applications","Entrypoint structure, exit codes, cross-platform scripts. Use when building command line utilities, scripts, or applications.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3386,3389],{"name":3387,"slug":3388,"type":15},"CLI","cli",{"name":20,"slug":21,"type":15},"2026-07-15T05:22:18.863572",{"slug":3392,"name":3392,"fn":3393,"description":3394,"org":3395,"tags":3396,"stars":22,"repoUrl":23,"updatedAt":3402},"dart-collect-coverage","collect Dart test coverage reports","Collect coverage using the coverage packge and create an LCOV report",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3397,3398,3401],{"name":20,"slug":21,"type":15},{"name":3399,"slug":3400,"type":15},"Reporting","reporting",{"name":3377,"slug":3378,"type":15},"2026-07-15T05:22:21.38636",{"slug":3404,"name":3404,"fn":3405,"description":3406,"org":3407,"tags":3408,"stars":22,"repoUrl":23,"updatedAt":3413},"dart-fix-runtime-errors","debug and fix Dart runtime errors","Uses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hot_reload.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3409,3410],{"name":20,"slug":21,"type":15},{"name":3411,"slug":3412,"type":15},"Debugging","debugging","2026-07-15T05:22:22.622501",{"slug":3415,"name":3415,"fn":3416,"description":3417,"org":3418,"tags":3419,"stars":22,"repoUrl":23,"updatedAt":3422},"dart-generate-test-mocks","generate mock objects for Dart tests","Define and generate mock objects for external dependencies using `package:mockito` and `build_runner`. Use when unit testing classes that depend on complex external services like APIs or databases.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3420,3421],{"name":20,"slug":21,"type":15},{"name":3377,"slug":3378,"type":15},"2026-07-15T05:22:42.607449",{"slug":3424,"name":3424,"fn":3425,"description":3426,"org":3427,"tags":3428,"stars":22,"repoUrl":23,"updatedAt":3434},"dart-migrate-to-checks-package","migrate test matchers to checks package","Replace the usage of `expect` and similar functions from `package:matcher`\nto `package:checks` equivalents.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3429,3430,3433],{"name":20,"slug":21,"type":15},{"name":3431,"slug":3432,"type":15},"Migration","migration",{"name":3377,"slug":3378,"type":15},"2026-07-15T05:22:31.276564",{"slug":3436,"name":3436,"fn":3437,"description":3438,"org":3439,"tags":3440,"stars":22,"repoUrl":23,"updatedAt":3444},"dart-resolve-package-conflicts","resolve Dart package version conflicts","Workflow for fixing package version conflicts. Use this when `pub get` fails due to incompatible package versions.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3441,3442,3443],{"name":20,"slug":21,"type":15},{"name":3411,"slug":3412,"type":15},{"name":17,"slug":18,"type":15},"2026-07-15T05:22:30.059335",{"items":3446,"total":2402},[3447,3452,3457,3463,3468,3473,3479,3485,3497,3503,3517,3527],{"slug":3370,"name":3370,"fn":3371,"description":3372,"org":3448,"tags":3449,"stars":22,"repoUrl":23,"updatedAt":3379},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3450,3451],{"name":20,"slug":21,"type":15},{"name":3377,"slug":3378,"type":15},{"slug":3381,"name":3381,"fn":3382,"description":3383,"org":3453,"tags":3454,"stars":22,"repoUrl":23,"updatedAt":3390},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3455,3456],{"name":3387,"slug":3388,"type":15},{"name":20,"slug":21,"type":15},{"slug":3392,"name":3392,"fn":3393,"description":3394,"org":3458,"tags":3459,"stars":22,"repoUrl":23,"updatedAt":3402},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3460,3461,3462],{"name":20,"slug":21,"type":15},{"name":3399,"slug":3400,"type":15},{"name":3377,"slug":3378,"type":15},{"slug":3404,"name":3404,"fn":3405,"description":3406,"org":3464,"tags":3465,"stars":22,"repoUrl":23,"updatedAt":3413},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3466,3467],{"name":20,"slug":21,"type":15},{"name":3411,"slug":3412,"type":15},{"slug":3415,"name":3415,"fn":3416,"description":3417,"org":3469,"tags":3470,"stars":22,"repoUrl":23,"updatedAt":3422},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3471,3472],{"name":20,"slug":21,"type":15},{"name":3377,"slug":3378,"type":15},{"slug":3424,"name":3424,"fn":3425,"description":3426,"org":3474,"tags":3475,"stars":22,"repoUrl":23,"updatedAt":3434},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3476,3477,3478],{"name":20,"slug":21,"type":15},{"name":3431,"slug":3432,"type":15},{"name":3377,"slug":3378,"type":15},{"slug":3436,"name":3436,"fn":3437,"description":3438,"org":3480,"tags":3481,"stars":22,"repoUrl":23,"updatedAt":3444},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3482,3483,3484],{"name":20,"slug":21,"type":15},{"name":3411,"slug":3412,"type":15},{"name":17,"slug":18,"type":15},{"slug":3486,"name":3486,"fn":3487,"description":3488,"org":3489,"tags":3490,"stars":22,"repoUrl":23,"updatedAt":3496},"dart-run-static-analysis","run static analysis and apply fixes","Execute `dart analyze` to identify warnings and errors, and use `dart fix --apply` to automatically resolve mechanical lint issues. Use during development to ensure code quality and before committing changes.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3491,3494,3495],{"name":3492,"slug":3493,"type":15},"Code Analysis","code-analysis",{"name":20,"slug":21,"type":15},{"name":3411,"slug":3412,"type":15},"2026-07-15T05:22:23.861119",{"slug":4,"name":4,"fn":5,"description":6,"org":3498,"tags":3499,"stars":22,"repoUrl":23,"updatedAt":24},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3500,3501,3502],{"name":20,"slug":21,"type":15},{"name":13,"slug":14,"type":15},{"name":17,"slug":18,"type":15},{"slug":3504,"name":3504,"fn":3505,"description":3506,"org":3507,"tags":3508,"stars":22,"repoUrl":23,"updatedAt":3516},"dart-skills-lint-setup","configure dart_skills_lint for Dart projects","Use this skill when you need to set up validation for AI agent skills in a Dart project for the first time.\nAdds the linter as a dev_dependency, creates a configuration file, and generates a baseline for legacy repos.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3509,3510,3513],{"name":20,"slug":21,"type":15},{"name":3511,"slug":3512,"type":15},"Plugin Development","plugin-development",{"name":3514,"slug":3515,"type":15},"QA","qa","2026-07-15T05:22:47.488998",{"slug":3518,"name":3518,"fn":3519,"description":3520,"org":3521,"tags":3522,"stars":22,"repoUrl":23,"updatedAt":3526},"dart-skills-lint-validation","validate agent skills with dart_skills_lint","Use this skill when you need to validate AI agent skills with dart_skills_lint — running the linter, interpreting failures, fixing violations, and authoring custom rules.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3523,3524,3525],{"name":20,"slug":21,"type":15},{"name":3511,"slug":3512,"type":15},{"name":3514,"slug":3515,"type":15},"2026-07-21T05:38:34.451024",{"slug":3528,"name":3528,"fn":3529,"description":3530,"org":3531,"tags":3532,"stars":22,"repoUrl":23,"updatedAt":3535},"dart-use-ffigen","generate FFI bindings with ffigen","Guide agents to use `package:ffigen` to automatically generate FFI bindings instead of writing them manually. Use this skill when a task involves writing new FFI bindings, extending C\u002FObjective-C\u002FSwift integrations, or replacing hand-crafted `dart:ffi` setups.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3533,3534],{"name":20,"slug":21,"type":15},{"name":17,"slug":18,"type":15},"2026-07-15T05:22:17.592351"]