🏗️ Create new module
1️⃣
Update Command
Update command to include your module name and fields
2️⃣
Run Command
Run command to generate module files, see the file changes after command is successful
3️⃣
Run Project
Run project to see the output and test new module CRUD
4️⃣
Customize
Understand the changes and customize according to your needs
Create new module for events
Let's create a new events module.
1. What would be the event schema
Following is the sample event schema that should be saved in database:
{
"id": "ev_5194601",
"accessCode": null,
"callToAction": "Select tickets",
"chk": "bba7",
"createdAt": 1737549701,
"currency": "usd",
"description": "<p>Hi, join our speed dating event and enjoy the life with your lovely partner.</p>",
"end": 1738794600,
"start": 1738778400,
"eventSeriesId": "es_1545937",
"hidden": false,
"name": "Speed Dating On Feb 5",
"onlineEvent": false,
"privateEvent": false,
"status": "published",
"ticketsAvailable": true,
"totalHolds": 0,
"totalIssuedTickets": 1,
"totalOrders": 1,
"unavailable": false,
"unavailableStatus": null
}
The Dart class should be created like this:
class Event {
final String id;
final String accessCode;
final String callToAction;
final String chk;
final int createdAt;
final String currency;
final String description;
final int end;
final int start;
final String eventSeriesId;
final bool hidden;
final String name;
final bool onlineEvent;
final bool privateEvent;
final String status;
final bool ticketsAvailable;
final int totalHolds;
final int totalIssuedTickets;
final int totalOrders;
final bool unavailable;
final String unavailableStatus;
}
2. Create Command
./starter.sh make <package> <module_snake> <module_camel> <modules_snake> <modules_camel> `<fields>`
Explanation of Each Parameter
<package>
: The Dart package name (e.g.,my_flutter_app
).<module_snake>
: The name of the module in snake_case (e.g.,article
).<module_camel>
: The name of the module in camelCase (e.g.,article
).<modules_snake>
: The plural form of the module name in snake_case (e.g.,articles
).<modules_camel>
: The plural form of the module name in camelCase (e.g.,articles
).<fields>
: A comma-separated list of fields for the module (e.g.,title:String,url:String
).
Example Usage
Suppose you want to create a module for article
with fields title
and url
. You would run:
./module.sh make flutter_boilerplate article article articles articles title:String,url:String
Command for Events module
tip
So the command will be:
./module.sh make flutter_boilerplate event event events events name:String,accessCode:String,callToAction:String,chk:String,currency:String,description:String,end:int,start:int,eventSeriesId:String,hidden:bool,onlineEvent:bool,privateEvent:bool,status:String,ticketsAvailable:bool,totalHolds:int,totalIssuedTickets:int,totalOrders:int,unavailable:bool,unavailableStatus:String
./module.sh make flutter_boilerplate mail mail mails mails name:String,address:String,isDuplicateAddress:bool,isAddressValidated:bool,isInValidAddress:bool,isDoNotMail:bool,isAddressForwardingEnabled:bool,tags:String