lessify_flutter 0.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

lessifyflutter #

Integration with Lessify API

Getting Started #

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

[0.2.0] - 25/05/2020 #

  • Add translation with named arguments and arguments

[0.1.1] - 21/05/2020 #

  • Update example

[0.1.0] - 21/05/2020 #

  • Update project according to publish suggestion

[0.0.1] - 20/05/2020 #

  • First Release with Translation and Lessify Integration

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:lessify_flutter/lessify_flutter.dart';
import 'package:lessify_flutter/translation_loader.dart';

void main() {
  runApp(LessifyApp(
    fallbackLocale: const Locale('en'),
    supportedLocales: [const Locale('en'), const Locale('de')],
    loader: LessifyTranslationLoader(
        spaceId: '9325a510-8de0-11ea-8d6d-493c632c6526',
        environment: 'master',
        apiKey: 'api-key-UhakG-fdb8a170-9286-11ea-8d6d-493c632c6526-IbKCV'),
    //loader: BundleAssetTranslationLoader(),
    child: MyApp(),
  ));
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return StreamBuilder(
        stream: LessifyApp.of(context).currentLocaleStream$,
        builder: (BuildContext context, AsyncSnapshot<Locale> snapshot) {
          return MaterialApp(
            locale: snapshot.data,
            title: 'Flutter Demo',
            localizationsDelegates: [
              LessifyApp.of(context).delegate,
              GlobalMaterialLocalizations.delegate,
              GlobalWidgetsLocalizations.delegate,
            ],
            supportedLocales: LessifyApp.of(context).supportedLocales,
            theme: ThemeData(
              primarySwatch: Colors.blue,
              visualDensity: VisualDensity.adaptivePlatformDensity,
            ),
            home: MyHomePage(title: 'Flutter Demo Home Page'),
          );
        });
  }
}

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

  final String title;

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

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

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  String _getLanguageCode(BuildContext context) {
    return Localizations.localeOf(context).languageCode;
  }

  @override
  Widget build(BuildContext context) {
    String currentLanguageCode = _getLanguageCode(context);
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                RaisedButton(
                  onPressed: () =>
                  {LessifyApp.of(context).changeLocale(Locale('en'))},
                  color: currentLanguageCode == 'en'
                      ? Theme.of(context).accentColor
                      : null,
                  child: Text('English'),
                ),
                const SizedBox(width: 30),
                RaisedButton(
                  onPressed: () =>
                  {LessifyApp.of(context).changeLocale(Locale('de'))},
                  color: currentLanguageCode == 'de'
                      ? Theme.of(context).accentColor
                      : null,
                  child: Text('German'),
                ),
              ],
            ),
            Text(translate('login.email')), // Translate key
            Text(translate('welcome', namedArgs: {'user': 'Alex'})), // Translate key with named args
            Text('Current Locale : ' + _getLanguageCode(context)),
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  lessify_flutter: ^0.2.0

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:lessify_flutter/lessify_flutter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [lessify_flutter] that is in a package requiring null.

Health suggestions

Format lib/global.dart.

Run flutter format to format lib/global.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
flutter_localizations 0.0.0
http ^0.12.1 0.12.1
rxdart ^0.24.1 0.24.1
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
http_parser 3.1.4
intl 0.16.1
meta 1.1.8 1.2.1
path 1.6.4 1.7.0
pedantic 1.9.0 1.9.1
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test