Metro CLI tool
- Introduction
- Install
- Make Commands
- App Icons
- Slate
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
Run the below command from the terminal
echo "alias metro='dart run nylo_framework:main'" >>~/.bash_profile && source ~/.bash_profile
If you open a project that uses Nylo, try to run the following in the terminal.
dart run nylo_framework:main
# or with the alias
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:stateful_widget
make:stateless_widget
make:provider
make:event
make:api_service
make:interceptor
make:theme
make:form
make:route_guard
make:config
slate
slate:publish
slate:install
Make controller
Making a new controller
You can make a new controller by running the below in the terminal.
dart run nylo_framework:main make:controller profile_controller
# or with the alias metro
metro make:controller profile_controller
This will create a new controller if it doesn't exist within the lib/app/controllers/
directory.
Forcefully make a controller
Arguments:
Using the --force
or -f
flag will overwrite an existing controller if it already exists.
metro make:controller profile_controller --force
Make model
Making a new model
You can make a new model by running the below in the terminal.
dart 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/
.
Make a model from JSON
Arguments:
Using the --json
or -j
flag will create a new model from a JSON payload.
dart run nylo_framework:main make:model product --json
# or with the alias metro
metro make:model product --json
Then, you can paste your JSON into the terminal and it will generate a model for you.
Forcefully make a model
Arguments:
Using the --force
or -f
flag will overwrite an existing model if it already exists.
dart run nylo_framework:main make:model product --force
# or with the alias metro
metro make:model product --force
Make page
- Making a new page
- Create a page with a controller
- Create an auth page
- Create an initial page
- Create a bottom navigation page
- Forcefully make a page
Making a new page
You can make a new page by running the below in the terminal.
dart run nylo_framework:main make:page product_page
# or with the alias metro
metro make:page product_page
This will create a new page if it doesn't exist within the lib/resources/pages/
directory.
Create a page with a controller
You can make a new page with a controller by running the below in the terminal.
Arguments:
Using the --controller
or -c
flag will create a new page with a controller.
dart run nylo_framework:main make:page product_page --controller
# or with the alias metro
metro make:page product_page -c
Create an auth page
You can make a new auth page by running the below in the terminal.
Arguments:
Using the --auth
or -a
flag will create a new auth page.
dart run nylo_framework:main make:page login_page --auth
# or with the alias metro
metro make:page login_page -a
Create an initial page
You can make a new initial page by running the below in the terminal.
Arguments:
Using the --initial
or -i
flag will create a new initial page.
dart run nylo_framework:main make:page home_page --initial
# or with the alias metro
metro make:page home_page -i
Create a bottom navigation page
You can make a new bottom navigation page by running the below in the terminal.
Arguments:
Using the --bottom-nav
or -b
flag will create a new bottom navigation page.
dart run nylo_framework:main make:page dashboard --bottom-nav
# or with the alias metro
metro make:page dashboard -b
Forcefully make a page
Arguments:
Using the --force
or -f
flag will overwrite an existing page if it already exists.
dart run nylo_framework:main make:page product_page --force
# or with the alias metro
metro make:page product_page --force
Make stateless widget
Making a new stateless widget
You can make a new stateless widget by running the below in the terminal.
dart 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.
Forcefully make a stateless widget
Arguments:
Using the --force
or -f
flag will overwrite an existing widget if it already exists.
dart run nylo_framework:main make:stateless_widget product_rating_widget --force
# or with the alias metro
metro make:stateless_widget product_rating_widget --force
Make stateful widget
Making a new stateful widget
You can make a new stateful widget by running the below in the terminal.
dart 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.
Forcefully make a stateful widget
Arguments:
Using the --force
or -f
flag will overwrite an existing widget if it already exists.
dart run nylo_framework:main make:stateful_widget product_rating_widget --force
# or with the alias metro
metro make:stateful_widget product_rating_widget --force
Make API Service
- Making a new API Service
- Making a new API Service with a model
- Make API Service using Postman
- Forcefully make an API Service
Making a new API Service
You can make a new API service by running the below in the terminal.
dart run nylo_framework:main make:api_service user
# or with the alias metro
metro make:api_service user_api_service
It will place the newly created API service in lib/app/networking/
.
Making a new API Service with a model
You can make a new API service with a model by running the below in the terminal.
Arguments:
Using the --model
or -m
option will create a new API service with a model.
dart run nylo_framework:main make:api_service user --model="User"
# or with the alias metro
metro make:api_service user --model="User"
It will place the newly created API service in lib/app/networking/
.
Use Postman to Make API Services
You can make new API services using Postman v2.1 collection files.
First, you must export your postman collection into a JSON file (using v2.1).
Copy the exported file into the public/assets/postman/collections
directory.
After copying the file into the above directory, go to the terminal and run the following command.
Arguments:
Using the --postman
or -p
option will create a new API service using a Postman collection.
dart run nylo_framework:main make:api_service my_collection_name --postman
# or with the alias metro
metro make:api_service my_collection_name --postman
This will prompt you to select a collection from the public/assets/postman/collections
directory.
Postman Environments
If your postman collection has an environment, export the file and add it to the public/assets/postman/environments
directory.
Then, run the below command.
dart run nylo_framework:main make:api_service collection --postman
# or with the alias metro
metro make:api_service collection --postman
It will prompt you to select an environment from the public/assets/postman/environments
directory.
What does it do?
It will also add Models to your project if your Postman collections have a saved response. You can check if your collection has saved responses by going to your Postman collection, then selecting a request. You should see a dropdown which will contain any saved responses.
The saved response name will be used for the Model name that Nylo will create.
Forcefully make an API Service
Arguments:
Using the --force
or -f
flag will overwrite an existing API Service if it already exists.
dart run nylo_framework:main make:api_service user --force
# or with the alias metro
metro make:api_service user --force
Make event
Making a new event
You can make a new event by running the below in the terminal.
dart run nylo_framework:main make:event login_event
# or with the alias metro
metro make:event login_event
This will create a new event in lib/app/events
.
Forcefully make an event
Arguments:
Using the --force
or -f
flag will overwrite an existing event if it already exists.
dart run nylo_framework:main make:event login_event --force
# or with the alias metro
metro make:event login_event --force
Make provider
Making a new provider
Create new providers in your application using the below command.
dart 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/
.
Forcefully make a provider
Arguments:
Using the --force
or -f
flag will overwrite an existing provider if it already exists.
dart run nylo_framework:main make:provider firebase_provider --force
# or with the alias metro
metro make:provider firebase_provider --force
Make theme
Making a new theme
You can make themes by running the below in the terminal.
dart run nylo_framework:main make:theme bright_theme
# or with the alias metro
metro make:theme bright_theme
This will create a new theme in lib/app/themes
.
Forcefully make a theme
Arguments:
Using the --force
or -f
flag will overwrite an existing theme if it already exists.
dart run nylo_framework:main make:theme bright_theme --force
# or with the alias metro
metro make:theme bright_theme --force
Make Forms
Making a new form
You can make a new form by running the below in the terminal.
dart run nylo_framework:main make:form car_advert_form
# or with the alias metro
metro make:form car_advert_form
This will create a new form in lib/app/forms
.
Forcefully make a form
Arguments:
Using the --force
or -f
flag will overwrite an existing form if it already exists.
dart run nylo_framework:main make:form login_form --force
# or with the alias metro
metro make:form login_form --force
Make Route Guard
Making a new route guard
You can make a route guard by running the below in the terminal.
dart run nylo_framework:main make:route_guard premium_content
# or with the alias metro
metro make:route_guard premium_content
This will create a new route guard in lib/app/route_guards
.
Forcefully make a route guard
Arguments:
Using the --force
or -f
flag will overwrite an existing route guard if it already exists.
dart run nylo_framework:main make:route_guard premium_content --force
# or with the alias metro
metro make:route_guard premium_content --force
Make Config File
Making a new config file
You can make a new config file by running the below in the terminal.
dart run nylo_framework:main make:config shopping_settings
# or with the alias metro
metro make:config shopping_settings
This will create a new config file in lib/app/config
.
Forcefully make a config file
Arguments:
Using the --force
or -f
flag will overwrite an existing config file if it already exists.
dart run nylo_framework:main make:config app_config --force
# or with the alias metro
metro make:config app_config --force
Build App Icons
You can generate all the app icons for IOS and Android by running the below command.
dart run flutter_launcher_icons:main
This uses the flutter_icons configuration in your pubspec.yaml
file.
Publishing files with Slate
If you are new to Slate packages, you can read more about them here.
Publishing files with Slate
You can publish files with Slate by running the below in the terminal.
dart run nylo_framework:main slate:publish my_slate_package
# or with the alias metro
metro slate:publish my_slate_package
This will publish all the files in your project.
Forcefully publish files with Slate
Arguments:
Using the --force
or -f
flag will overwrite any existing files in your project.
dart run nylo_framework:main slate:publish --force
# or with the alias metro
metro slate:publish --force
Install and publish with Slate
You can install and publish files with Slate by running the below in the terminal.
dart run nylo_framework:main slate:install my_slate_package
# or with the alias metro
metro slate:install my_slate_package
This will install the Slate package and publish all the files in your project.