Basics

Metro CLI tool



Introduction

Metro is a CLI tool that works under the hood of the Nylo framework. It provides a lot of helpful tools to speed up development.


Install

Mac guide

  1. Open your bash_profile
sudo open ~/.bash_profile
  1. Add this alias to your bash_profile
...
alias metro='flutter pub run nylo_framework:main'
  1. Then run the following
source ~/.bash_profile

If you open a project that uses Nylo, try to run the following in the terminal.

metro

You should see an output similar to the below.

Usage: 
    command [options] [arguments]

Options
    -h

All commands:

 make
  make:controller
  make:model
  make:page
  make:stateless_widget
  make:stateful_widget
  make:theme
  make:event
  make:provider
  make:api_service
  make:theme

 appicons
  appicons:build


Make controller

You can make a new controller by running the below in the terminal.

flutter pub run nylo_framework:main make:controller profile_controller

Or with the alias metro

metro make:controller profile_controller

This is will create a new controller if it doesn't exist within the lib/app/controllers/ directory.


Make model

You can make a new model by running the below in the terminal.

flutter pub run nylo_framework:main make:model product

Or with the alias metro

metro make:model product

It will place the newly created model in lib/app/models/.

If you plan to use the same model to represent objects from your API's, add it to your lib/config/decoders.dart modelDecoders map.

Arguments:

Using the --force flag will overwrite an exiting class if it already exists.

metro make:model product --force

Using the --storage flag will create a new model that is storable to the users local storage.

metro make:model product --storable

Learn more on Storable models here.


Make page

You can make a new page by running the below in the terminal.

flutter pub run nylo_framework:main make:page product_page

Or with the alias metro

metro make:page product_page

This is will create a new page if it doesn't exist within the lib/resources/pages/ directory. Nylo also supports the use of controllers. Use the below command to create a new page with a controller.

metro make:page product_page -c

Create a page with a controller.


Make stateless widget

You can make a new stateless widget by running the below in the terminal.

flutter pub run nylo_framework:main make:stateless_widget product_rating_widget

Or with the alias metro

metro make:stateless_widget product_rating_widget

The above will create a new widget if it doesn't exist within the lib/resources/widgets/ directory.


Make stateful widget

You can make a new stateful widget by running the below in the terminal.

flutter pub run nylo_framework:main make:stateful_widget product_rating_widget

Or with the alias metro

metro make:stateful_widget product_rating_widget

The above will create a new widget if it doesn't exist within the lib/resources/widgets/ directory.


Make API Service

You can make a new API service by running the below in the terminal.

flutter pub run nylo_framework:main make:api_service user

Or with the alias metro

metro make:api_service user_api_service

You can provide the --url="https://myapi.com" option to create an API Service that will use the url as the Base URL.

flutter pub run nylo_framework:main make:api_service user --url="https://myapi-baseurl.com"

You can provide a --model="User" option to tell Nylo to create a new API Service with the following methods: find, create, delete, update and fetchAll.

flutter pub run nylo_framework:main make:api_service user --model="User"

It will place the newly created API service in lib/app/networking/.


Make event

You can make a new event by running the below in the terminal.

flutter pub run nylo_framework:main make:event login_event

Or with the alias metro

metro make:api_service login_event

This is will create a new event in lib/app/events.

You will also need to add the event to your lib/config/events.dart map for it to be used.


Make provider

Create new providers in your application using the below command.

flutter pub run nylo_framework:main make:provider firebase_provider

Or with the alias metro

metro make:provider firebase_provider

It will place the newly created provider in lib/app/providers/.

You will also need to add the provider to your lib/config/providers.dart map for it to be used.


Make theme

You can make themes by running the below in the terminal.

flutter pub run nylo_framework:main make:theme bright_theme

Or with the alias metro

metro make:theme bright_theme


Build App Icons

You can generate all the app icons for IOS and Android by running the below command.

flutter pub run flutter_launcher_icons:main

This uses the flutter_icons configuration in your pubspec.yaml file.