EZ Flutter

EZ Flutter is a collection of widgets, packages and many more usefull things, mixed up in little framework. The aim is to standardize the structure of an flutter app.

Table of Contents

  1. Install
  2. Import
  3. Features
  4. Usage
  5. Used Packages
  6. Changelog
  7. Copyright and license

Install

pubspec.yaml

Update pubspec.yaml and add the following line to your dependencies.

dependencies:
  ez_flutter: ^0.1.3

Import

Import the package with :

import 'package:ez_flutter/ez_flutter.dart';

Features

Global Messaging

Display a message to the user from anywhere inside the app with just one line of code.

Automatic Application Configuration

Loading a configuration from json file and make it available everywhere inside the app.

Multilanguage Support

Build in translation feature that can be used everywhere inside the app.

Buildin customizable transition screen

EZ Flutter provides a customizable loading screen to switch between to screens after some work is done.

Usage

Important information

  • All widgets and model classes from the EZ Flutter framework start with "Ez" to easily identify them.

Start an EZ Flutter APP

  void main() => EzRunner.run(MyHomePage(title: 'Flutter Demo Home Page'));

Display messages

Global Messaging is handled with a BLOC and widget added as the body of the Scaffold. Load the EzMessageBloc via the EzBlocProvider using the get method.

Add the EzGlobalMessageWrapper as the body to a Scaffold.

Scaffold{
  appBar: ...
  body: EzGlobalMessageWrapper(
    MyWidget(
      ...
    )
  )
}

Add a EzMessage to the bloc. The supported types are :

  • success (default color : 0xFF4CAF50)
  • info (default color : 0xFF2196F3)
  • warning (default color : 0xFFFF9800)
  • error (default color : 0xFFF44336)
    BlocProvider.of<GlobalBloc>(context)
        .get<EzMessageBloc>(EzMessageBloc)
        .addition
        .add(EzMessage("This is a success message", "success"));

It is also possible to customize the color for each type of message within the application.json file.

{
  "msg_success_color" : "0xFF1B5E20",
  "msg_info_color" : "0xFF0D47A1",
  "msg_warning_color" : "0xFFE65100",
  "msg_error_color" : "0xFFB71C1C",
}

Use application settings

The EzRunner loads automatically a json file with the name application.json from the assets directory. The EzRunner accepts a path to a environment and a custom settings file. The application.json should only contain configuration that refers to the EZ Framework. Your environment .json file should contain configuration depending on the current environment the app is running. Add all other configuration that belongs to your app in the custom .json file.

Remember to add the assets folder to your pubspec.yaml file!

EzRunner.run(CustomWidget() ,
      envPath: "assets/env_dev.json",
      customPath: "assets/myapp.json");

The settings can be accessed via the EzSettings class.

Map<String, dynamic> appSettings = EzSettings.app();
Map<String, dynamic> envSettings = EzSettings.env();
Map<String, dynamic> customSettings = EzSettings.custom();

Translation

Translation is handled by different .json files that contain the translation for each language supported by your app. The translation files are automatically loaded by the EzRunner at startup. Create a .json file with the pattern locale_$loacle.json under the locale folder for each supported language.

Remember to add the locale folder to your pubspec.yaml file!

Example: locale_en.json && locale_de.json

//locale_en.json
{
  "some_message": "This is some message!"
}
//locale_de.json
{
  "some_message": "Dies ist eine Nachricht!"
}

Add all supported locales to the EzRunner at startup.

EzRunner.run(CustomWidget(),const [Locale('en'), Locale('de'), Locale('de')]);

Access the translation within your app.

EzTranslator.of(context).text("some_message");

Adding custom BLOCs to the BlocProvider

Typically your app will use some blocs written by yourself. The EzRunner will add the given blocs to the EzGlobalBloc at startup. You can access each bloc everywhere inside the app. Your Bloc has to extend EzBlocBase.

  class MyCustomBloc extends BlocBase {
    // some stuff
  }

  BlocProvider.of<GlobalBloc>(context)
      .get<MyCustomBloc>(MyCustomBloc)
      .addition
      .add("Hello World");

Transition from Screen A to B

Use the EzTransition to switch from Screen A to B after some work is done. The "work" is defined by the toProcess argument.

void toProcess() async {
  await new Future.delayed(const Duration(seconds: 3));
  Navigator.push(
    context,
    MaterialPageRoute(
      builder: (context) => MyNewScreen(),
    ));
}

FlatButton(
  child: Text("Start transition"),
  onPressed: () {
    Navigator.push(
      context,
      MaterialPageRoute(
        builder: (context) => EzTransition(EzPulse(), toProcess,backgroundColor: Colors.white)),
    );
  },
)

Build in loading widgets

EZ Flutter offers some loading animations that can be used for the EzTransition.

Used Packages

Changelog

For a detailed changelog, see the CHANGELOG.md file

MIT License

Copyright (c) 2019 Ephenodrom

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Libraries

ez_flutter