Site icon Flutter Packages | Pub dev Packages – Flutter Mobile App World

Slidy – CLI package manager and template for Flutter

Slidy

CLI package manager and template generator for Flutter. Generate Modules, Pages, Widgets, BLoCs, Controllers, and tests.

Slidy supports rxBLoC, flutter_bloc, and mobx.

Why should I use it?

Slidy’s goal is to help you structure your project in a standardized way. Organizing your app in Modules formed by pages, repositories, widgets, BloCs, and also create unit tests automatically. The Module gives you a easier way to inject dependencies and blocs, including automatic dispose. Also helps you installing the dependencies and packages, updating and removing them. The best is that you can do all of this running a single command.

Motivations

We realized that the project pattern absence is affecting the productivity of most developers, so we’re proposing a development pattern along with a tool that imitates NPM (NodeJS) functionality as well as template generation capabilities (similar to Scaffold ).

About the Proposed Pattern

The structure that slidy offers you, it’s similar to MVC, where a page keeps it’s own business logic classes(BloC).

We recommend you to use bloc_pattern when structuring with slidy. It offers you the module structure(extending the ModuleWidget) and dependency/bloc injection, or you will probably get an error.

To understand bloc_pattern package, take a look at the README.

We also use the Repository Pattern, so the folder structure it’s organized in local modules and a global module. The dependencies(repositories, BloCs, models, etc) can be accessed throughout the application.

Sample folder structure generated by slidy:

Installation

  1. Activate the slidy using the pub:          flutter pub global activate slidy     
  2. Type slidy --version to make sure everything is working properly. This command should return the installed version.

Commands:

upgrade:

Updates slidy’s version:

slidy upgrade

start:

Create the basic structure of your project (make sure that your “lib” folder it’s empty).

slidy start

Then choose your provider:

Then choose your State Manager:

Mobx

And you will get this Structure:

Flutter Bloc:

And you will get this Structure:

Bloc With RxDart

And you will get this Structure:

If you have the flutter_bloc or flutter_mobx package in pubspec, the generation of pages, widgets, and bloc defaults to the installed manager default.

Options

The command allows to specify provider and state manager using the following options:

-p <provider_name>

Options:
flutter_modular / bloc_pattern

Example:
slidy start -p flutter_modular
-s <state_manager_name>

Options: 
mobx / flutter_bloc / rxdart
Example:
slidy start -s mobx
slidy start -p flutter_modular -s mobx

This command asks for permission to erase lib folder. If you don’t want to see the warning, type the -e (erase) flag:

slidy start -p flutter_modular -s mobx -e

run:

Runs the scripts in pubspec.yaml:

slidy run open_folder

install:

Installs or update the packages in dependencies:

slidy install rxdart dio bloc_pattern

or you can just use the i command (both are the same)

slidy i rxdart dio bloc_pattern

Install packages as dev_dependency:

slidy i mockito --dev

uninstall:

Removes a package

slidy uninstall dio 

You can also remove a dev_dependency using the flag –dev

generate:

Creates a module, page, widget or repository including its BloC class.

NOTE: You can replace “g” with “generate” command.

Creates a new module:

slidy g module folder_name

or

slidy g m folder_name

NOTE: You can create a “Complete Module” with Module, Page, Bloc/Controller, tests for Page and for Bloc/Controller using the flag -c

Creates a new page + BloC:

slidy g page folder_name/pages

or

slidy g p folder_name/pages

Creates a new widget + BloC:

slidy g widget folder_name/widgets

or

slidy g w folder_name/widgets

NOTE: You can create a page or widget using its respective BLoC using the flag -b

Create a new repository

slidy g r folder_name/repositories

Create a new service

slidy g s folder_name/services

Create a new model

slidy g mm folder_name/model

You can also use “repository” in “r”‘s place, but it will have the same function.

Unit Tests:

Generate unit tests on the test folder for you.

slidy test folder_name/

Common errors:

Windows:

If you got this error when trying to run the pub global activate slidy, then you will have to set the environment variables manually:

If you have any doubt about setting up the system variables, watch this video.

For more details join our Telegram Group Flutterando

Download CLI package manager and template for Flutter Source Code on GitHub

https://github.com/Flutterando/slidy

Exit mobile version