-
Notifications
You must be signed in to change notification settings - Fork 3
RocketCLI
Mohammed CHAHBOUN edited this page Jan 20, 2026
·
3 revisions
rocket_cli is a command-line tool designed to eliminate the boilerplate of creating RocketModel classes. It converts any JSON (from a string or a file) into fully optimized Dart code.
Activate the CLI globally using Dart:
dart pub global activate rocket_cliYou can generate a model from a JSON string:
rocket_cli -j '{"id": 1, "name": "John"}' -n UserOr from a JSON file:
rocket_cli -f data.json -n Result-
Automatic Serialization: Generates
fromJsonandtoJsonmethods. -
Field Constants: Automatically creates
conststrings for field keys to prevent typos. -
Performance Optimized: Generates
updateFieldslogic with built-in support for Selective Rebuilds. - Nested Detection: Automatically detects nested objects and lists, generating appropriate sub-models.
- DateTime Support: Automatically detects and handles ISO8601 date strings.
When you run the tool, it creates a Dart file containing:
-
Constants:
const String userIdField = "id"; -
Model Class:
class User extends RocketModel<User> { ... } -
Methods:
-
fromJson: To parse API data. -
toJson: To send data back. -
updateFields: Optimized for high-performance state updates.
-
Manually writing model serialization is error-prone and tedious. rocket_cli ensures your models are consistent, follow best practices, and are optimized for the latest features of Flutter Rocket.