i18nu 0.0.1+1

i18nu Internationalization package #

It is a simple package that offers some convenience internationalization and localization classes.

It is supposed to be a intermediary localization step between the translation format and in code usage.

I18n: Is the internationalization widget that is responsible for keeping track of a locale and allow subwidgets on the tree to both access or alter it. L10n: Is the localization interface where that the application should rely upon. L10nDelegate: The LocalizationsDelegate that is registered with the WidgetApp (MaterialApp/CupertinoApp). It is responsible for managing L10n instances whenever locale changes.


import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:i18nu/i18nu.dart';

import 'localization_delegate.dart';
import 'localizations.dart';

void main() => runApp(I18n(child: MyApp()));

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    const supported = [
      Locale('en', 'US'),
      Locale('pt', 'BR'),
      // TODO: add multi plural language(s)
    final i18n = I18n.of(context);

    return MaterialApp(
      title: 'I18nu Demo',
      theme: ThemeData(),
      localizationsDelegates: [
        const MyL10nDelegate(
          supported: supported,
          dataSource: AssetBundleL10nDataSource(bundlePath: 'l10n/'),
      home: const MyHomePage(supportedLocales: supported),
      locale: i18n.locale,
      supportedLocales: supported,

class MyHomePage extends StatefulWidget {
  const MyHomePage({
    Key key,
    @required this.supportedLocales,
  }) : super(key: key);

  final List<Locale> supportedLocales;

  _MyHomePageState createState() => _MyHomePageState();

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

  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    final homepageL10n = HomePageL10n.of(context);
    final counterL10n = CounterL10n.of(context);

    return Scaffold(
      appBar: AppBar(title: Text(homepageL10n.title)),
      body: SingleChildScrollView(
        padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 24),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
              children: Map.fromIterable(
                key: (dynamic loc) => loc,
                value: (dynamic locale) => Text(locale.toString()),
              groupValue: Localizations.localeOf(context),
              onValueChanged: (locale) => updateLocale(context, locale),
            const Divider(height: 32),
              homepageL10n.hello(name: 'Name', world: 'Flutter'),
              style: theme.textTheme.title,
              style: theme.textTheme.subtitle,
              padding: const EdgeInsets.symmetric(vertical: 8),
              children: const {
                'male': Text('MALE'),
                'female': Text('FEMALE'),
                '': Text('OTHER'),
              groupValue: _gender,
              onValueChanged: updateGender,
            const Divider(height: 32),
              style: theme.textTheme.display1,
              child: Text(counterL10n.resetCounter),
              onPressed: resetCounter,
      floatingActionButton: FloatingActionButton(
        onPressed: incrementCounter,
        tooltip: counterL10n.clickMe,
        child: Icon(Icons.add),

  void incrementCounter() => setState(() => _counter++);

  void resetCounter() => setState(() => _counter = 0);

  void updateGender(String gender) => setState(() => _gender = gender);

  void updateLocale(BuildContext context, Locale locale) =>
      I18n.of(context).locale = locale;

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  i18nu: ^0.0.1+1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:i18nu/i18nu.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 16, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Fix lib/src/i18n.dart. (-0.50 points)

Analysis of lib/src/i18n.dart reported 1 hint:

line 33 col 17: 'inheritFromWidgetOfExactType' is deprecated and shouldn't be used. Use dependOnInheritedWidgetOfExactType instead. This feature was deprecated after v1.12.1..

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://github.com/nubank/i18nu was unreachable.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
path ^1.6.4 1.6.4
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
mockito ^4.0.0