createWidget method
Implementation
Future<void> createWidget({
required String widgetName,
}) async {
Utility.stdoutWrite(text: kCommonOrFeature);
String choice = stdin.readLineSync()!.toLowerCase();
if (choice == kCommon) {
await createWidgetProcess(
widgetName: widgetName,
destinationPath: kCommonWidgetPath,
isCommon: true,
);
} else if (choice == kFeatureCommand) {
Utility.stdoutWrite(text: kEnterYourFeatureName);
String featureName = stdin.readLineSync()!.toLowerCase();
Directory destinationDirectory = Directory('$kLibFeatures$featureName');
if (destinationDirectory.existsSync()) {
await createWidgetProcess(
widgetName: widgetName,
destinationPath: PathHandler().getScreenPath(
featureName: featureName,
),
isCommon: false,
);
} else {
Utility.errorPrinter(
text: '$kFeatureLabel $featureName $kDoesNotExist',
);
}
} else {
Utility.errorPrinter(text: kCommonOrFeatureError);
exit(1);
}
}