makeForm static method

Future<void> makeForm(
  1. String className,
  2. String value, {
  3. String folderPath = formsFolder,
  4. bool forceCreate = false,
})

Creates a new Form.

Implementation

static Future<void> makeForm(
  String className,
  String value, {
  String folderPath = formsFolder,
  bool forceCreate = false,
}) async {
  String name = className.replaceAll(RegExp(r'(_?form)'), "");

  String filePath = '$folderPath/${name.snakeCase}_form.dart';

  await _makeDirectory(folderPath);
  await _checkIfFileExists(filePath, shouldForceCreate: forceCreate);
  await _createNewFile(
    filePath,
    value,
    onSuccess: () {
      final linkText = name.snakeCase;
      final link = MetroConsole.hyperlink(linkText, filePath);
      MetroConsole.writeInGreen('[Form] $link created 🎉');
    },
  );
}