Flutter
En esta página
Overview #
better_i18n is a pure Dart + Flutter SDK that loads translations from the better-i18n CDN at runtime. It uses the same CDN infrastructure as the Expo and iOS SDKs — meaning your translations are managed in one place and delivered to all platforms.
- CDN-driven — Translations update without app store releases
- Offline-first — 4-tier fallback: memory → CDN → persistent storage → static data
- Reactive UI —
BetterI18nProviderrebuilds widgets automatically on locale change - No codegen — No build steps, no generated files, no native modules
Features #
- Offline-First — 4-tier fallback chain ensures translations are always available — even without network.
- Reactive UI — Locale switches rebuild the widget tree instantly via ChangeNotifier.
- Locale Switching —
context.setI18nLocale('tr')— pre-loads translations before switching. - Testing Utilities —
MemoryStorageandBetterI18nScopemake widget testing straightforward. - No Codegen — Pure Dart — no build_runner, no generated files, no native modules required.
Quick Start #
pubspec.yaml
dependencies:
better_i18n: ^0.1.0lib/main.dart
import 'package:better_i18n/better_i18n.dart';
import 'package:flutter/material.dart';
void main() {
runApp(
BetterI18nProvider(
projectId: 'your-org/your-project',
defaultLocale: 'en',
child: const MyApp(),
),
);
}lib/home_screen.dart
import 'package:better_i18n/better_i18n.dart';
import 'package:flutter/material.dart';
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(context.t('common.welcome')),
Text(context.t('common.greeting', args: {'name': 'Osman'})),
],
),
),
);
}
}Guide #
- Setup — Installation, configuration, and locale switching.
- Offline & Caching — How the 4-tier fallback chain and persistent storage work.
- API Reference — Complete API documentation for all exports.
Comparison #
| Feature | Flutter | Expo | iOS |
|---|---|---|---|
| Language | Dart | TypeScript | Swift |
| i18n library | better_i18n | i18next | better-i18n-ios |
| UI framework | Flutter widgets | React Native | SwiftUI / UIKit |
| Offline support | Built-in | Built-in | Built-in |
| Reactive rebuilds | ChangeNotifier | React state | @Observable / ObservableObject |
| Persistent cache | SharedPrefsStorage | MMKV / AsyncStorage | UserDefaults |
| No codegen | Yes | Yes | Yes |
Choose Flutter for cross-platform mobile apps written in Dart. For React Native / Expo apps, see Expo. For native iOS, see iOS.
AI Tooling #
Now that you've integrated the SDK, your AI agent can check coverage, translate keys, and publish — all without leaving your editor.
- MCP Server — Translate keys, check coverage, and publish — all from your editor via Cursor, Claude Code, or Windsurf.
- Agent Skill — Permanent better-i18n knowledge for your AI agent — SDK patterns, CDN behavior, key conventions. No prompts needed each session.
Better I18N