ccci_run 1.0.17 ccci_run: ^1.0.17 copied to clipboard
This project sets up a basic folder structure and creates default files for a Flutter application. The structure aims to provide a clear organization for project components, making it easier to manage [...]
CCCI RUN #
CCCI RUN is a tool designed to set up a basic folder structure and create default files for a Flutter application. The organized structure facilitates easier management and scalability of the application.This project sets up a basic folder structure and creates default files for a Flutter application. The structure aims to provide a clear organization for project components, making it easier to manage and scale the application.
Features #
- Init Project: Initializes the project by creating the folder structure.
- Create Model: Generates a model file with freezed annotation and JSON serialization.
- Create API: Creates an API file with pre-defined methods for interacting with API endpoints.
- Create Repository: Generates a repository file for handling data operations and API interactions.
Usage #
To use CCCI RUN, execute the following commands:
Init Project #
USAGE:
dart run ccci_run init
This command initializes the project by creating the necessary folder structure within the lib
directory.
Create Model #
USAGE:
dart run ccci_run --create-model <name>
Creates a model file with the specified name under the lib/core/models
directory. The generated model file includes annotations for JSON serialization.
// This is an automatically generated model file.
import 'package:freezed_annotation/freezed_annotation.dart';
part '${name}_model.freezed.dart';
part '${name}_model.g.dart';
@freezed
class ${_capitalize(name)}Model with _${_capitalize(name)}Model {
const factory ${_capitalize(name)}Model({
int? id,
bool? isActive,
DateTime? createdAt,
}) = _${_capitalize(name)}Model;
factory ${_capitalize(name)}Model.fromJson(Map<String, dynamic> json) =>
_${_capitalize(name)}ModelFromJson(json);
}
Create API #
USAGE:
dart run ccci_run --create-api <name>
Generates an API file for interacting with the specified API. The file includes methods for making HTTP requests and handling responses.
// This is an automatically generated API file.
// Modify it to implement your API endpoints and logic.
import 'package:ccci_utility/ccci_utility.dart';
import 'package:dio/dio.dart';
/// A class for interacting with the $name API.
///
/// This class provides methods to communicate with the $name API endpoints.
/// You can extend and modify this class to implement specific API functionalities.
class ${_capitalize(name)}Api extends BaseApi {
/// Constructs a new instance of the ${_capitalize(name)}Api.
///
/// [dioClient]: The DioClient instance for making HTTP requests.
${_capitalize(name)}Api(DioClient dioClient) : super(dioClient, "/core/v1.0/auth");
/// Add your API endpoint methods and logic here.
///
/// For example:
///
/// ```dart
/// Future<void> fetch${_capitalize(name)}Data() async {
/// try {
/// final response = await dioClient.get(route);
/// // Handle response...
/// } catch (error) {
/// AppLogger.error("\$error");
/// rethrow;
/// }
/// }
/// ```
}
Create Repository #
USAGE:
dart run ccci_run --create-repositories <name>
Creates a repository file for handling data operations and API interactions. This file integrates the model and API classes to facilitate data management.
// Imports the model class for $name and the corresponding API class
import 'package:$packageName/cores/models/$name/${name}_model.dart';
import 'package:$packageName/cores/services/api/${name}_api.dart';
/// A repository class for interacting with the $name API and handling data operations.
///
/// This class provides methods to interact with the $name API endpoints and handle data operations.
/// You can extend and modify this class to implement specific data handling functionalities.
class ${_capitalize(name)}Repository extends BaseRepository{
/// Instance of the $name API for making HTTP requests.
final ${_capitalize(name)}Api ${name}Api;
/// Constructs a new instance of the ${name}Repository.
///
/// [${name}Api]: The ${name}Api instance for making HTTP requests.
${_capitalize(name)}Repository(this.${name}Api) : super(${name}Api, ${_capitalize(name)}Model.fromJson);
}
Folder Structure #
The following folders are created within the lib
directory:
lib/commons
: Common utility functions and classes.lib/constants
: Application-wide constants.lib/core/models
: Data models.lib/core/services/api
: API-related services.lib/core/services/providers
: Providers for state management.lib/core/services/repositories
: Data repositories.lib/core/local_storage
: Local storage utilities.lib/modules
: Modules for different features of the application.