tomodels

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

tomodels

Tomodels #
Tomodels is a simpel and powerfull json to dart generator.
this tools use https://github.com/javiercbk/json_to_dart to base engine with several customization
Features #

API to JSON
JSON to Dart

Installation #
Use global activate to install this package into your device :
dart pub global activate --source git https://github.com/alalawy/tomodels.git
copied to clipboard
Usage #
First, you must init the config to your project
tomodels init
copied to clipboard

after init the config, you can edit the config file at

├── tomodels
│ ├── config
│ │ ├── config.dart
copied to clipboard
config.dart
String jsonpath = "tomodels/json";
String modelspath = "tomodels/models";

List<Map<String, dynamic>> endpoint = [
{
"name": "",
"url": "",
"methods": "",
"headers": {"Content-Type": "application/json"},
"body": {}
}
];

copied to clipboard
you can change json path or models path directory.
For generate API to JSON just change the endpoint Map in config dart with yours
Example :
String jsonpath = "tomodels/json";
String modelspath = "tomodels/models";

List<Map<String, dynamic>> endpoint = [
{
"name": "product",
"url": "https://dummyjson.com/products/1",
"methods": "get",
"headers": {"Content-Type": "application/json"},
"body": {}
}
];

copied to clipboard
for methods you can change it to get, post, put or delete.
After you change the config just run command :
tomodels create json
copied to clipboard
├── tomodels
│ ├── config
│ │ ├── config.dart
│ ├── json
│ │ ├── product.json
copied to clipboard
For generate JSON to Dart you must have file .json in the directory you specified in config.dart or you can generate it with the create json command
for generate models without generate json, you must change the name in Map endpoint at config.dart according to the name of your .json file
Example
String jsonpath = "tomodels/json";
String modelspath = "tomodels/models";

List<Map<String, dynamic>> endpoint = [
{
"name": "product",
"url": "",
"methods": "",
"headers": {"Content-Type": "application/json"},
"body": {}
},
{
"name": "category"
}, // if you just use this config to generate models from .json without fetching data, you can just type name like this without url, methods, etc
];

copied to clipboard
After you change the config just run
tomodels create models
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.