as2f 0.1.4

  • Readme
  • Changelog
  • Installing
  • 59

AS2F - Android Strings To Flutter #

Overview #

Kotlin based generator for converting android xml string resources into one i18n dart class that can be used in flutter projects.

Inspired by flutter_i18n project by long1eu except no need to use IntelliJ or arb files.

Usage in Dart/Flutter Project #

 as2f: ^0.1.2

Then run the following command.

flutter pub run as2f:codegen

NOTE: You can add --run-once and --dry-run parameters to the above command.

NOTE: You can try running pub run as2f:codegen in the example folder to play with the carrots_sample 🥕🥕

This fetches the jar from jitpack containing the code generator and executes it in a watch mode. It will bootstrap as2f.yaml file for you. This file describes where your Android string files are and where the generated class should go.

- name: android_strings # base name
  source: someplace/main/res # lookup place for all values-lang/strings.xml files
  target: lib/gen/i18n.dart # place where your i18n class should go

The structure of the generated class is much like the one by flutter_i18n meaning you can just follow their setup intructions:

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return new MaterialApp(
      onGenerateTitle: (BuildContext context) => S.of(context).app_name,
      localizationsDelegates: const <LocalizationsDelegate<WidgetsLocalizations>>[
            // You need to add them if you are using the material library.
            // The material components usses this delegates to provide default 
            // localization      
      supportedLocales: S.delegate.supportedLocales,
      title: 'Flutter Demo',
      theme: new ThemeData(
      home: new MyHomePage(title: 'Flutter Demo Home Page'),

If you want to have nice formatting, make sure you have dart-sdk in you PATH, it's included with flutter sdk, so you can e.g.:

export PATH="$PATH:/path/to/flutter/bin/cache/dart-sdk/bin"

Supported Features #

  • Normal Strings
  • Strings with arguments
  • Plurals (only integer part)

Code Organization #

  • cli - Command Line Tool based on patrol, uses as2f as a module
  • as2f - All the code generation logic & unit tests, contributions welcome.
  • bin - dart script wrapper around jar file allowing you to run pub run as2f:codegen right from your project

0.1.4 #

  • fix as2f broken under Windows OS issue #4

0.1.3 #

  • reduce lint analyze noise.

0.1.2 #

  • improve dartfmt location resolution

0.1.1 #

  • fix dartfmt breaking code generation

0.1.0 #

  • initial release

Use this package as a library

1. Depend on it

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

  as2f: ^0.1.4

2. Install it

You can install packages from the command line:

with pub:

$ pub get

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

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 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Maintenance suggestions

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and as2f.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


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