Kelven Galvão
Jul 13 · 3 min read

Slidy is a CLI to help you to structure, increase the maintainability, productivity, organization and manage your packages(If you want) of your project.

The state management approach that we chose is BLoC using the bloc_pattern that was born born in november, 2018 as the first package for bloc provider.

Slidy follow the recommended patterns of Dart Docs.

What it does:

  • Create modules structured.
  • Create BLoCs and Views with a provider and dependency injection.
  • Install and update packages via command line.

How to use:

Slidy was build and works in a DartVM different of the present in Flutter, so we need activate it.

pub global activate slidy

OBS: Take care in terminal because sometimes is needed to add a variable on PATH

After that we can use slidy -h to see all the commands available.

Let’s do a tour in the primary commands:

start: create a basic structure of your project(you need certificate that you don’t have any important archive on there)

slidy start

install: install or pudate a new package or packages:

slidy install rxdart dio bloc_pattern

You can use tha flag — dev to install in dev_dependency

slidy install flutter_launcher_icons — dev

To unninstall a package:

slidy uninstall dio

Generating the structure of your project

We’ll need bloc_pattern at this moment to use dependency injection and BLoC.

After used slidy start that prepares your project to modular structure, we’ll create our modules, pages, blocs using slidy that generate the archives e add the blocs in the dependency injection of your module automatically.

Let’s see some commands:

To create a new module:

slidy generate module home/home

This command above create an archive called home_module.dart that is a ModuleWidget from bloc_pattern.

class HomeModule extends ModuleWidget {

//Inject the blocs
@override
List<Bloc<BlocBase>> get blocs => [
Bloc((i) => HomeBloc())),
];

//Inject the dependencies
@override
List<Dependency> get dependencies => [];

//main widget
@override
Widget get view => HomeWidget();

//shortcut to pick up dependency injections from this module
static Inject get to => Inject<HomeModule>.of();

}

ModuleWidget is a implementation of BlocProvider, is where we inject our BLoCs and Repositories. After that we can access the data using:

HomeModule.to.getBloc<HomeBloc>(); // to get BLoCHomeModule.to.getDependency<AnyRepository>(); // take injection of any dependency or repository.

To create a new page and your respective BLoC

slidy generate page home/home

This command create a Stateful Widget called home_page.dart, a BLoC called home_bloc.dart and add this bloc in the dependency injection of HomeModule.

To create a new widget and your respective BLoC:

slidy generate widget home/components/card_home/card_home

This command create a Stateless Widget called card_home_widget.dart inside the directory lib/src/home/components/card_home .

Leave your feedback ;)

We are a brazilian community. Follow us on Youtube and in Twitter, be part of our telegram group with 2000+ members.

Flutterando

Flutterando, a maior comunidade de Dart do Brasil!

Kelven Galvão

Written by

Flutter ❤. Mobile Developer at https://smartercode.com.br/. GitHub: https://github.com/irvine5k

Flutterando

Flutterando, a maior comunidade de Dart do Brasil!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade