State management in a Flutter app vs in a Kotlin app. MVI and Clean Code included.

Picture taken from here

Briefly about the theory

Clean Code — what we mean

Now about MVVM, MVC, MVP, MVI, MVU and others

Choosing an example for the first step

Consider the nuances of Riverpod

Let’s start

Let’s separate the state and logic from the user interface: see. on github see how Codingstory (

What happens if you launch the application? on github see how Codingstory (

Thank you Captain Obvious!

makes it run.

Let’s try to add a feature: see. on github see how Codingstory (

Provider chains

Now let’s cast the spell Clean Code (Clean Architecture) on this code

  • lib / main.dart — remove unnecessary
  • lib / presentation / widgets / counter_widget.dart — group widgets into package / presentation / widgets /
  • lib / presentation / pages / home_page.dart — into the page package (analogous to fragment from Android), and the entire structure of the application will resemble the Single Activity approach
  • lib / presentation / manager / bindings / counter_view_binding.dart — select provider binding in a separate file in presentation / manager / bindings package
  • lib / data / models / counter_model.dart — transfer models to the data layer

Add a healthier look with MVI

Add View States

Code generation

Render contract

Where is the problem and why did I make these changes

“Our providers are becoming bloated divine classes with the logic of state and business scattered all over the place.” =

Somewhere on Reddit

Polishing with Clean Code


Software Engineers, technology geek, prefer cats and racoons.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Create an array of dates for looping in Azure Data Factory

Cover image

Certainly image effort a wait.


Writing NPM Modules With Typescript Made Easy

[Recap] AMA with DOM Chain Global Ambassador Jonah Schulman (January 14, 2022)

Hello World!

Codility Algorithm Practice Lesson 10: Prime and Composite Numbers, Task 1: CountFactors— a Python…


Death By A Thousand Pythonic Keystrokes

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
Nick Maletsky

Nick Maletsky

Software Engineers, technology geek, prefer cats and racoons.

More from Medium

How to handle Firebase Authentication in clean architecture using Jetpack Compose?

internal error in Cloud Firestore. SOLVED

Jetpack Compose: MVVM State management in a simple way

Modern data storage on Android: Meet Jetpack DataStore — Part 2/2