generateViewHelper method
void
generateViewHelper(
- String pathPackageLocal2dart
)
Implementation
void generateViewHelper(String pathPackageLocal2dart) {
final dir = join(pathPackageLocal2dart, 'lib', 'models');
DirectoryHelper.createDir(dir);
final Map views = local2dart['view'] ?? {};
views.forEach((viewName, view) {
final Map columns = view['column'] ?? {};
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: views,
tableName: viewName,
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, '${viewName.toString().snakeCase}_view.dart'),
className: '${viewName.toString().pascalCase}View',
importForeign: importForeign,
constructor: constructor,
constructorAssign: constructorAssign,
variables: variables,
toMap: toMap,
fromMap: fromMap,
fromMapWithJoin: fromMapWithJoin,
paramCopyWith: paramCopyWith,
valueCopyWith: valueCopyWith,
props: props,
);
});
}