Flutter
Flutter
The Flutter integration is provided as a self-contained build_runner builder in examples/flutter/plugin. It runs intl-ai fill during flutter pub run build_runner build and has zero runtime overhead because all translations are written to disk before the Flutter app is bundled.
Copy the builder
Copy examples/flutter/plugin/ into your Flutter project (for example, to ./tools/intl_ai_builder/). The builder is not published as a package, so you own and can customize the code.
Configure build.yaml
Add the builder to your app’s build.yaml:
targets:
$default:
builders:
intl_ai_flutter|intl_ai:
enabled: true
options:
configPath: "intl-ai.toml"
executable: "intl-ai"
verbose: false
Update the import path in build.yaml to match where you copied the builder, for example:
builders:
intl_ai:
import: "package:my_app/tools/intl_ai_builder/lib/builder.dart"
Create intl-ai.toml
locale_dir = "assets/locales"
source = "en"
targets = ["es"]
[provider]
kind = "http"
base_url = "https://api.openai.com/v1"
model = "your-model-name"
api_key = "${env:OPENAI_API_KEY}"
Run build_runner
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
The builder invokes:
intl-ai fill --config intl-ai.toml
Builder options
| Option | Type | Default | Description |
|---|---|---|---|
configPath |
String |
intl-ai.toml |
Path to your config file, relative to the package root. |
executable |
String |
intl-ai |
Command used to invoke the CLI. Use npx intl-ai or bunx intl-ai if you do not want a global install. |
verbose |
bool |
false |
Forward CLI output to the build runner log. |
How it works
The builder is registered on the $package$ asset and writes an intl-ai.done marker file. When build_runner runs, it invokes the intl-ai CLI once per package. Add intl-ai.done to your .gitignore; it is only used to track build completion.
Runtime usage
Load the generated JSON files with your preferred i18n library (easy_localization, i18n_extension, flutter_gen, etc.). The builder only writes translations; it does not impose a runtime API.
Requirements
- Dart SDK 3.0+
intl-aiCLI onPATH- An
intl-ai.tomlfile and locale directory
Example
See examples/flutter for a complete working app.