flutter_localization
1.0.0, released 2 weeks ago by an unverified publisher
In-app localization package supporting map data or JSON assets with runtime language switching.
What it does
Allows developers to add in-app localization using either in-memory Map data or JSON asset files. It provides methods to initialize languages, translate keys, format strings with arguments, and change locales at runtime.
AI-written summary of version 1.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want to manage app translations using in-memory Dart maps or flat JSON assets.
- You need dynamic runtime language switching backed by a ChangeNotifier.
Skip it when
- You require code generation for type-safe translation keys.
- Your translation JSON files require nested objects, arrays, or non-string values.
Strengths
- Supports both Map data and JSON asset files as sources.
- Persists selected locales automatically using shared_preferences.
- Provides built-in text formatting and native language name lookups.
Weaknesses
- JSON translation files must be strictly flat objects containing only string values.
- No compile-time key checking or code generation.
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
Call WidgetsFlutterBinding.ensureInitialized() and FlutterLocalization.instance.ensureInitialized() in main, then initialize the localization instance in initState.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await FlutterLocalization.instance.ensureInitialized();
runApp(const MyApp());
}Alternatives
Packages that do the same job and could replace flutter_localization.
Works with
Packages commonly used together with flutter_localization: ones it builds on, ones built on it, and its own family.