Skip to content
pubscout

flutter_locales

3.0.6, released 8 months ago by an unverified publisher

Easily localize Flutter apps using JSON files with dynamic locale switching and persistent storage.

WASM-readyUnverified publisher
$ flutter pub add flutter_locales
Source repository

What it does

Allows developers to translate a Flutter app into multiple languages using local JSON asset files. It provides widgets and extensions to change app locales dynamically at runtime and automatically saves the selected language preference.

AI-written summary of version 3.0.6, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want to manage app localizations using JSON files stored in assets.
  • Users need to change the app language dynamically within the UI without restarting.
  • You want to remember the user's selected language across app restarts.

Skip it when

  • You require compile-time type-safe keys via code generation.
  • Your localization requires complex ICU message format features not handled by simple JSON assets.

Strengths

  • Easy setup with JSON assets
  • Runtime locale switching with automatic persistence
  • Handy extensions and helper widgets like LocaleText

Weaknesses

  • No compile-time verification of localization keys
  • Relies on JSON asset loading rather than native ARB/Intl code generation

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
3

Add json files in assets/locales/, declare them in pubspec.yaml, initialize Locales in main(), and wrap MaterialApp with LocaleBuilder.

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Locales.init(['en', 'fa', 'ps']);
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return LocaleBuilder(
      builder: (locale) => MaterialApp(
        localizationsDelegates: Locales.delegates,
        supportedLocales: Locales.supportedLocales,
        locale: locale,
        home: HomeScreen(),
      ),
    );
  }
}

Alternatives

Packages that do the same job and could replace flutter_locales.

Works with

Packages commonly used together with flutter_locales: ones it builds on, ones built on it, and its own family.