generateTableHelper method

void generateTableHelper(
  1. String pathPackageLocal2dart
)

Implementation

void generateTableHelper(String pathPackageLocal2dart) {
  final dir = join(pathPackageLocal2dart, 'lib', 'models');
  DirectoryHelper.createDir(dir);

  final Map tables = local2dart['table'] ?? {};

  tables.forEach((tableName, table) {
    final Map columns = table['column'] ?? {};
    final Map foreigns = table['foreign'] ?? {};

    List<String> importForeign = [];
    List<String> constructor = [];
    List<String> constructorAssign = [];
    List<String> variables = [];
    List<String> toMap = [];
    List<String> fromMap = [];
    List<String> fromMapWithJoin = [];
    List<String> props = [];
    List<String> paramCopyWith = [];
    List<String> valueCopyWith = [];

    columnToList(
        columns: columns,
        tables: tables,
        tableName: tableName,
        foreigns: foreigns,
        callback: (
          importForeignCallback,
          constructorCallback,
          constructorAssignCallback,
          variablesCallback,
          toMapCallback,
          fromMapCallback,
          fromMapWithJoinCallback,
          propsCallback,
          paramCopyWithCallback,
          valueCopyWithCallback,
        ) {
          importForeign = importForeignCallback;
          constructor = constructorCallback;
          constructorAssign = constructorAssignCallback;
          variables = variablesCallback;
          toMap = toMapCallback;
          fromMap = fromMapCallback;
          fromMapWithJoin = fromMapWithJoinCallback;
          props = propsCallback;
          paramCopyWith = paramCopyWithCallback;
          valueCopyWith = valueCopyWithCallback;
        });

    generateModel(
      path: join(dir, '${tableName.toString().snakeCase}_table.dart'),
      className: '${tableName.toString().pascalCase}Table',
      importForeign: importForeign,
      constructor: constructor,
      constructorAssign: constructorAssign,
      variables: variables,
      toMap: toMap,
      fromMap: fromMap,
      fromMapWithJoin: fromMapWithJoin,
      paramCopyWith: paramCopyWith,
      valueCopyWith: valueCopyWith,
      props: props,
    );
  });
}