intl_helpers 1.0.2

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

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 pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or 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]
63
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
25
Overall:
Weighted score of the above. [more]
37
Learn more about scoring.

We analyzed this package on Apr 25, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.4.7

Platforms

Detected platforms:

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running flutter packages pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.2.1-dev.2.0.flutter-None.
 
 Because intl_helpers requires SDK version >=1.8.0 <2.1.0, version solving failed.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Support the latest stable Dart SDK in pubspec.yaml. (-20 points)

The SDK constraint in pubspec.yaml doesn't allow the latest stable Dart SDK release.

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is getting outdated. (-4.93 points)

The package was last published 54 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.1.0