interactive_i18n 0.0.6 copy "interactive_i18n: ^0.0.6" to clipboard
interactive_i18n: ^0.0.6 copied to clipboard

Package for manage translations jsons and widget to let user choose the language

interactive_i18n #

Flutter package to take care of internationalization

Features #

  • InteractiveLocalization widget to give context and the localesPath to get the translation jsons
  • 'Getter translation by adding a dot t in the end of the string'.t
  • InteractiveI18nSelector widget that you just need to add to let the user switch between languages

Getting started #

Add the dependency to your pubspec.yaml:

interactive_i18n: ^0.0.3

Usage #

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return InteractiveLocalization(
      availableLanguages: const ['en', 'pt'],
      languageUpdated: () => setState(() {}),
      child: Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
          actions: [
            InteractiveI18nSelector(
              onLanguageSelected: (language) {
                debugPrint('User picked language $language');
              },
            )
          ],
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                'You have pushed the button this many times:'.t,
              ),
              Text(
                '$_counter',
                style: Theme.of(context).textTheme.headline4,
              ),
            ],
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: _incrementCounter,
          tooltip: 'Increment',
          child: const Icon(Icons.add),
        ),
      ),
    );
  }
}

Tests #

Check this test to validate missing translations https://github.com/ivofernandes/interactive_i18n/blob/main/example/test/check_translations_test.dart

Like us on pub.dev #

Package url: https://pub.dev/packages/interactive_i18n/example

2
likes
140
points
176
downloads

Publisher

verified publisherincaview.com

Weekly Downloads

Package for manage translations jsons and widget to let user choose the language

Homepage
Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

country_icons, flutter, provider, shared_preferences

More

Packages that depend on interactive_i18n