Pakete, Repositories und App-Kategorien suchen

Paketdetailsv1.1.1

native_toolchain_rust

Rust-Unterstützung für Dart-Build-Hooks. Baut und bundelt Ihren Rust-Code automatisch mit Ihrem Dart-Code!

AndroidiOSLinuxmacOSWindows
30-Tage-Downloads
83.800
Likes
29
Pub-Punkte
160

Paket installieren

flutter pub add native_toolchain_rust

Paketübersicht

Aus öffentlichen Paketdaten erstellte Orientierung.

Ein Flutter/Dart-Paket, das die nahtlose Integration von Rust-Code in Dart-Projekte ermöglicht. Es kompiliert und bundelt Rust-Bibliotheken automatisch zusammen mit Dart-Code mithilfe von Build-Hooks, was die Entwicklung über Sprachen hinweg vereinfacht. Ideal für leistungsintensive Komponenten wie Kryptografie, Datenverarbeitung oder systemnahe Operationen. Unterstützt alle wichtigen Plattformen einschließlich Android, iOS, Linux, macOS und Windows.

Anwendungsfälle

  • Hochleistungs-Rust-Bibliotheken in Flutter-Anwendungen integrieren
  • Kryptografische Funktionen mit Rust erstellen
  • Optimierung datenintensiver Berechnungen
  • Plattformspezifische Native-Erweiterungen erstellen
  • Sicheren Zugriff auf niedrigstufige Systemfunktionen aktivieren

Hauptmerkmale

  • Automatisierte Rust-Kompilierung über Build-Hooks
  • Plattformübergreifende Unterstützung (Android, iOS, Linux, macOS, Windows)
  • Nahtlose Dart-Rust-Interoperabilität
  • Minimale Boilerplate-Einrichtung
  • Eingebaute Abhängigkeitsverwaltung

Geeignet für

  • Entwickler, die in Flutter hochleistungsfähigen Native-Code benötigen
  • Teams, die Rust für die Kernlogik verwenden
  • Projekte, die sichere, schnelle Berechnung erfordern
  • Plattformübergreifende Native Erweiterungen
  • Dart-Entwickler erkunden die Integration von Rust

Hinweise

  • Benötigt eine auf dem Host-System installierte Rust-Toolchain
  • Kann Build-Zeiten aufgrund der Rust-Kompilierung erhöhen
  • Eingeschränkter Debugging-Support für Rust-Code
  • Plattformspezifische Build-Konfigurationen können erforderlich sein
  • Lernkurve für Rust-Anfänger

Original-README

Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.

🧱 native_toolchain_rust 🦀

Build Status Github Stars MIT License


Rust support for Dart's build hooks.

Why native_toolchain_rust?

  1. It's opinionated. That might sound bad, but it's opinionated in the way that keeps you from shooting yourself in the foot.
  2. Does more with less. The API is incredibly easy to use: the only thing you need to provide is assetName, and the rest is auto-magically figured out. (But you can still tweak the functionality as much as you need to!)

Getting Started

  1. Install rustup, for Rust, on your development computer (if you are a library author, consumers of your package will have to do the same)
  2. Run flutter pub add native_toolchain_rust hooks for Flutter or dart pub add native_toolchain_rust hooks for Dart-only
  3. See Code Setup

Code Setup

native_toolchain_rust will look (by default) for native/ or rust/ (customizable) in your Dart package's root. If you haven't already, create a Cargo.toml and rust-toolchain.toml in your chosen Rust directory; keep reading for what these two files must contain (but don't worry if you forget, you'll get a helpful error message).

hook/build.dart
import 'package:hooks/hooks.dart';
import 'package:native_toolchain_rust/native_toolchain_rust.dart';

void main(List<String> args) async {
  await build(args, (input, output) async {
    await RustBuilder(
      assetName: 'src/my_ffi_bindings.g.dart',
      // ...maybe enable some Cargo features or something in here too
    ).run(input: input, output: output);
  });
}
Cargo.toml

Keep at least the following in your Cargo.toml.

[package]
name = "my-crate-name" # pick a name, doesn't matter

[lib]
crate-type = ["staticlib", "cdylib"] # THESE ARE IMPORTANT!
rust-toolchain.toml

Keep at least the following in your rust-toolchain.toml.

[toolchain]
# WARNING: *do not* use `stable`, `beta`, or `nightly` (alone) for the channel!
# You must specify a version number/date in order to ensure reproducible builds.
channel = "1.90.0" # or newer. another example: `nightly-2025-01-01`

# The targets you want to support; these are the default:
targets = [
  # Android
  "armv7-linux-androideabi",
  "aarch64-linux-android",
  "x86_64-linux-android",

  # iOS (device + simulator)
  "aarch64-apple-ios",
  "aarch64-apple-ios-sim",
  "x86_64-apple-ios",

  # Windows
  "aarch64-pc-windows-msvc",
  "x86_64-pc-windows-msvc",

  # Linux
  "aarch64-unknown-linux-gnu",
  "x86_64-unknown-linux-gnu",

  # macOS
  "aarch64-apple-darwin",
  "x86_64-apple-darwin",
]

Kategorien

Abhängigkeiten

Abhängigkeiten 6 Einträge

Quell-Repository

Projekte, die dieses Paket verwenden

Noch keine Daten verfügbar.

Ranglisten