createCubitByPath method
Function to create cubit by name and path
Implementation
Future<bool> createCubitByPath(String name, String path) async {
printYellow('Create cubit "$name"');
if (path.isNotEmpty) {
path += '/';
}
String screenPath = '${path}cubit';
if (await File('$screenPath/cb_${name}.dart').exists()) {
printRed('Cubit "$name" already exists');
return false;
}
Creator curDir = Creator(screenPath);
await curDir.createFile(
fileName: 'st_${name}.dart', templates: Templates.cubitState(name));
await curDir.createFile(
fileName: 'cb_${name}.dart', templates: Templates.screenCubit(name));
if (SgMetadata.instance.git) {
print(screenPath);
await Shell(commandVerbose: false, workingDirectory: projectDir)
.run('git add \"$screenPath\"');
}
printGreen('Create cubit "$name" success');
return true;
}