Sign in

Flutter Developer from Azerbaijan | Founder of Azerbaijan Flutter Users Community

During the development, we need to be sure that everything works fine. So, we need to test our code. There are several testing stages and one of them is Unit Testing. In this article, we will write simple Bloc that will fetch and filter items. Then we will write test for our Bloc.

Add Dependencies

During the coding, we will need following dependencies. Add following to dependencies:

Equatable is used to simplify equality processes (In Dart if we compare to object using == it will not compare them with fields, will compare with hashcode and == operator. …


Sometimes we want to make our apps support dark mode. It is easy with Flutter, but reusable code and decoupling of presentation and business logic is an important topic. That is why I shall try to implement enable/disable dark mode and store the current state of theme using flutter_bloc library.

1. Add all dependencies

Make sure you have added all libraries correctly.

Then run the flutter pub get command to get all libraries

day_night_switcher is an optional. You can pass it and use simple Switch in Flutter.

2. Create SharedPreferencesService to store ThemeMode

We will store ThemeMode in SharedPreferences. If the value is true, dark mode is enabled, otherwise not.


Localization is one of the most important thing in mobile development. Flutter makes it easy for us, but we need to write our code more readable and decouple business logic and presentation. That’s why, I shall try to make localization using flutter_bloc library.

1. Adding library to pubspec.yaml

Make sure you have added libraries to your pubspec.yaml.

2. Creating SharedPreferencesService

First of all, we should create SharedPreferencesService for storing user’s language selection. It seems like following:

3. Language enum for selection

It is optional part, you can pass it. I have created simple enum to simplfy language selection.

4. Language Jsons

Create assets folder in your app level and inside it create langs

Kanan Yusubov

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store