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

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:interactive_i18n/interactive_i18n.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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(() {}),
      localesPath: 'assets/locales/',
      child: Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
          actions: [
            Container(
              margin: const EdgeInsets.only(right: 5),
              child: 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.headlineMedium,
              ),
            ],
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: _incrementCounter,
          tooltip: 'Increment',
          child: const Icon(Icons.add),
        ),
      ),
    );
  }
}
2
likes
150
pub points
4%
popularity

Publisher

verified publisherincaview.com

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

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

country_icons, flutter, provider, shared_preferences

More

Packages that depend on interactive_i18n