Giter Site home page Giter Site logo

ancronik / bloc-preferences Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 10.39 MB

Flutter BLoC Preferences

License: MIT License

Kotlin 0.63% Swift 0.60% Objective-C 0.06% Dart 98.71%
flutter-examples flutter flutter-demo bloc flutter-bloc flutter-bloc-pattern flutter-translate flutter-bloc-translate flutter-shared-preferences flutter-bloc-shared-preferences

bloc-preferences's Introduction

BLoC Preferences with internationalization

Implementation of application preferences and internationalization using BLoC and Clean Architecture pattern. This is not library (but it could become one), it is just example of my implementation that could make life easier to someone else. I'm new to Flutter so probably there are things that could be done easier/prettier. I tried to keep things simple while experimenting with libraries that are pretty cool.

Feature application_preferences contains implementation part, while feature test_app is here only for showing this implementation in action.

Internationalization

Internationalization is implemented really simple, I didn't want to include some localization library so some simple implementation is made using translation files (en.json and hr.json). There is TranslationFileRepository which loads JSON files from assets folder and Translator which handles language changes and getting translations. Because presentation layer shouldn't be aware of Translator, there is i18n package in core which provides method for translating and changing language.

Application preferences

There is entity ApplicationPreferences which should contain preferences that we want to store. With some work this could be full extendable, but you can easily add your own keys that you want to store. BLoC implementation is pretty simple, and we have only two states. Initial state is loaded because get operation on shared preferences is not async so we can easily fetch stuff. If that wouldn't be the case, we would need to add new state (e.g. loading) and new event (e.g. load) and make main Stateful so that we can put event load in initState.

Unit tests

They are not the greatest, but they exists :)

Building application

You need to build stuff with build runner flutter pub run build_runner build --delete-conflicting-outputs (instead of build you can use watch for continuous build).

Test application

It consist of two pages, home and settings

alt text

bloc-preferences's People

Contributors

ancronik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.