Meet flx CLI: A Clean Architecture Generator CLI for Flutter Developers
Md Rakibul Haque Sardar

Md Rakibul Haque Sardar @md_rakibulhaquesardar_

About: Experienced software engineer with 4+ years in full-stack development. Skilled in Flutter, Node.js, and React Native. Passionate about coding, tech innovation, and creating scalable, user-friendly web

Location:
Rajshahi, Bangladesh
Joined:
Jan 20, 2025

Meet flx CLI: A Clean Architecture Generator CLI for Flutter Developers

Publish Date: Jul 13
0 0

flx: Generate Clean Architecture for Flutter in Seconds


Introduction

As a Flutter developer, you've probably found yourself stuck in a messy codebase at some point — controllers everywhere, logic bleeding into UI, and files dumped in one huge folder. If you've ever said:

"I just want to generate my project structure properly using Clean Architecture..."

Then you're going to love this.

I created flx, a lightweight Flutter CLI tool that automatically generates a modular, clean architecture structure in seconds, with support for GetX and Bloc out of the box.


The Problem

Flutter gives us freedom, but too much freedom can lead to inconsistent folder structures, spaghetti logic, and poor scalability. Especially when you're working in a team, it's hard to maintain:

  • Folder organization
  • Clean separation of layers
  • State management patterns
  • Reusability and testability

This is where flx steps in — to standardize the project structure from day one.


What is flx?

flx is a command-line tool built in Dart, designed to help Flutter developers generate feature-based, clean-architecture-friendly folder structures with a single command.

It's heavily inspired by the feature-first modular approach, using Clean Architecture principles.

Key Features

  • ⚙️ Clean Architecture structure: presentation, domain, data
  • 🧱 Feature-based folders (lib/features/auth, etc.)
  • 🧠 State manager support: GetX and Bloc
  • 🔧 Configuration via .flxrc.json
  • Minimal boilerplate to get started fast

Here's an example of the generated structure for a feature like 'auth':

lib/features/auth/
├── data/
│   ├── datasources/
│   ├── models/
│   └── repositories/
├── domain/
│   ├── entities/
│   ├── usecases/
│   └── repositories/
└── presentation/
    ├── pages/
    ├── controllers/ or bloc/
    └── bindings/
Enter fullscreen mode Exit fullscreen mode

No more guessing. No more messy folders.


How to Install

dart pub global activate flx
Enter fullscreen mode Exit fullscreen mode

Then run:

flx config --state getx    # or bloc
flx gen feature auth
Enter fullscreen mode Exit fullscreen mode

Done. Your feature is ready with clean layers and structure.


Boilerplate Included

Every generated feature comes with:

  • Folder structure for data, domain, presentation
  • Ready-to-code files (controller, bloc, usecase, etc.)
  • Configurable support for custom state managers (more coming)

Why Clean Architecture?

Because separation of concerns matters.

By following Clean Architecture:

  • Your code becomes modular
  • It's easier to test
  • You avoid tight coupling
  • You scale like a pro

Docs & Source Code


Final Thoughts

Flx was born out of my frustration with cluttered projects. If it helps even one other dev build better, faster, and cleaner — it's worth it.

If you're building serious Flutter apps, give flx a try and let me know what you think. Contributions, ideas, and feedback are always welcome!

Comments 0 total

    Add comment