intl_helpers 1.0.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 83

menu_swipe_helpers

Build Status

Helpers to handle basic globalization.

Show intl_helper example.

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing package code, view the documentation.

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:intl_helpers/intl_helpers.dart';

import 'l10n/messages_all.dart';

void main() {
  LocaleNotifier.init(
      locale: new Locale('fr', 'FR'), initializeMessages: initializeMessages);
  runApp(new MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    LocaleNotifier.instance.addListener(() {
      setState(() {});
    });
  }

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Intl Helper Example',
      locale: LocaleNotifier.instance.locale,
      localizationsDelegates: createBasicLocalizationsDelegates(
          supportedLanguages: ['fr', 'en'],
          initializeMessages: initializeMessages),
      supportedLocales: [
        new Locale('en', 'US'), // English
        new Locale('fr', 'FR'), // French
      ],
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(title: 'Intl Helper Example Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String localeName = 'FR';

  String welcome(name) => Intl.message('Bienvenue, $name',
      name: "_MyHomePageState_welcome",
      args: [name],
      desc: 'message de bienvenue avec nom');

  @override
  void initState() {
    super.initState();
    LocaleNotifier.instance.addListener(() {
      setState(() {
        localeName = LocaleNotifier.instance.locale.languageCode.toUpperCase();
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new Center(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Text(
              GenericHelperLocalizations.of(context).welcome,
              style: Theme.of(context).textTheme.display1,
            ),
            new SizedBox(
              height: 32.0,
            ),
            new Text(
              welcome('Alice'),
              style: Theme.of(context).textTheme.display2,
            ),
            new SizedBox(
              height: 32.0,
            ),
            new Text(
              GlobalMessage.instance.welcomeGlobal,
              style: Theme.of(context).textTheme.display1,
            ),
            new SizedBox(
              height: 32.0,
            ),
            new Text(
              MaterialLocalizations.of(context).signedInLabel,
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: new FloatingActionButton(
        child: new Text(localeName),
        onPressed: _toggleLocale,
      ),
    );
  }

  void _toggleLocale() {
    if (LocaleNotifier.instance.locale.languageCode == 'fr') {
      LocaleNotifier.instance.update(new Locale('en', 'US'));
    } else {
      LocaleNotifier.instance.update(new Locale('fr', 'FR'));
    }
  }
}

class GlobalMessage {
  /// constructor not allowed, only singleton
  GlobalMessage._();

  /// singleton instance
  static final GlobalMessage instance = new GlobalMessage._();

  /// welcome global sample
  String get welcomeGlobal => Intl.message("Bienvenue à tous !",
      name: "welcomeGlobal", args: [], desc: "welcome message");
}

Use this package as a library

1. Depend on it

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


dependencies:
  intl_helpers: ^1.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:intl_helpers/intl_helpers.dart';
  
Version Uploaded Documentation Archive
1.0.2 Apr 6, 2018 Go to the documentation of intl_helpers 1.0.2 Download intl_helpers 1.0.2 archive
0.0.1 Mar 30, 2018 Go to the documentation of intl_helpers 0.0.1 Download intl_helpers 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
74
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
83
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4
  • Flutter: 0.9.5

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.1.0
flutter 0.0.0
flutter_localizations 0.0.0
intl ^0.15.2 0.15.7
Transitive dependencies
collection 1.14.11
meta 1.1.6
path 1.6.2
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
test >=0.12.0 <=0.13.0