# Flutter

Source: https://rerune.io/docs/flutter

Set up the ReRune Flutter SDK to keep generated AppLocalizations calls and add published translation values, runtime languages, and revision-driven rebuilds.

Package: rerune 1.9.1. Requirements: Flutter 3.27+, Dart 3.6+. Overview: https://rerune.io/flutter-localization

## Install and generate

Source: https://rerune.io/docs/flutter#install

Terminal · install:

```
flutter pub add rerune:^1.9.1
```

Start with Flutter localizations and ARB resources configured in the app. Generate the native localization API first, then generate the ReRune overlay. Run both generators again when keys or signatures change, and once after you upgrade the SDK. The generated code tells ReRune which placeholders each message accepts, so it can skip updates your app cannot display. Keep your ARB files under lib so the generator can record which keys each language has.

Terminal · generate localization code:

```
flutter gen-l10n
dart run rerune
```

Video: [Localize a Flutter app with a coding agent](https://www.youtube.com/watch?v=sKpWlV_Cad8). A short walkthrough of agent-assisted onboarding, ARB migration, SDK setup, and an OTA text update.

## Prepare exported ARB files when needed

Source: https://rerune.io/docs/flutter#prepare-arb

Flutter gen-l10n does not accept offset:0 in an ICU plural, even though that form can appear in API-exported ARB files. The SDK includes prepare-arb to create a Flutter-compatible copy. Use this step when your exported catalogs contain that syntax; ordinary Flutter-compatible ARBs can keep the standard generation sequence.

Keep source ARBs directly in lib/l10n, for example lib/l10n/app_en.arb. Point Flutter at the derived lib/l10n/flutter directory with the configuration below. prepare-arb takes no options and uses these fixed source and output directories.

l10n.yaml · use prepared catalogs:

```
arb-dir: lib/l10n/flutter
template-arb-file: app_en.arb
output-dir: lib/l10n/gen
output-localization-file: app_localizations.dart
output-class: AppLocalizations
```

Terminal · prepare, then generate:

```
dart run rerune prepare-arb
flutter gen-l10n
dart run rerune
```

> **Keep generated catalogs separate:** prepare-arb owns lib/l10n/flutter and removes stale generated locale files. Keep CLI sync pointed at the source ARBs in lib/l10n. Nonzero bundled plural offsets are rejected instead of being silently rewritten.

## Initialize the generated configuration

Source: https://rerune.io/docs/flutter#setup

Dart · main.dart startup:

```
import 'package:flutter/widgets.dart';
import 'package:rerune/rerune.dart';
import 'l10n/gen/app_localizations.rerune.g.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await ReRune.setup(
    otaPublishId: '<READ_ONLY_OTA_PUBLISH_ID>',
    localizations: reRuneAppLocalizationsConfig,
  );
  runApp(const MyApp());
}
```

Replace the generated import path and configuration name with those produced for your localization class. MyApp is your existing application widget. Setup restores available cache; a network update can happen afterward.

## Rebuild when text changes

Source: https://rerune.io/docs/flutter#refresh

Dart · inside the app widget build method:

```
ReRuneBuilder(
  builder: (_) => MaterialApp(
    localizationsDelegates: ReRune.localizationsDelegates,
    supportedLocales: ReRune.supportedLocales,
    home: const HomeScreen(),
  ),
)
```

HomeScreen represents your existing starting screen. ReRuneBuilder rebuilds the wrapped subtree when localization revisions change. Existing widgets otherwise retain their rendered text until another rebuild occurs. Keep your current theme, routes, and application settings on MaterialApp.

Use ReRune.supportedLocales for a language picker that includes fetched dashboard languages. Store the selected locale in app state and pass it to MaterialApp.locale when the user chooses an override.

Video: [Add a Flutter language without rebuilding](https://www.youtube.com/watch?v=wd7SIYxP0QU). Add and publish French, discover it through ReRune.supportedLocales, and restore it from cache in the same Flutter build. Recorded with Flutter SDK 1.1.0.

- [Preview drafts with OTA staging](https://rerune.io/docs/staging#sdk-setup)

## Fallback and release boundaries

Source: https://rerune.io/docs/flutter#limits

ReRune follows Flutter's own fallback order. For de_AT it tries dashboard de_AT, your bundled de_AT text, dashboard de, your bundled de text, then the dashboard text of your template ARB language and your bundled template text. A language the app does not bundle also ends at the template language. Code generated before SDK 1.9.0 keeps the old order, which ends at the main language. If a published translation uses a placeholder your app does not provide, ReRune skips that whole language update and keeps the last texts that worked. Keep your bundled translations. New getters or changed placeholders still need code generation and an app release.

Runtime plural selection follows these rules. Exact selectors such as =1 compare the original count. Plural categories and # use count minus the nonnegative integer offset; explicit count arguments retain the original value. A category such as one is not an implicit exact =1 match.

- [Flutter package and setup reference](https://pub.dev/packages/rerune)
- [Flutter API reference](https://pub.dev/documentation/rerune/latest/)

- See also: [Troubleshooting](https://rerune.io/docs/troubleshooting)

---

Part of the ReRune documentation (https://rerune.io/docs). Every chapter with a summary: https://rerune.io/llms.txt. Every chapter in one file: https://rerune.io/llms-full.txt. ReRune is not Rerun (rerun.io), the robotics data visualization tool.
