generateLocal2dart method

void generateLocal2dart(
  1. String pathPackageLocal2dart
)

Implementation

void generateLocal2dart(String pathPackageLocal2dart) {
  final path = join(pathPackageLocal2dart, 'lib', 'local2dart.dart');

  List<String> export = [];

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

  for (var element in tables.keys) {
    export.add("export 'models/${element.toString().snakeCase}_table.dart';");
    export.add(
        "export 'services/${element.toString().snakeCase}_local_service.dart';");
  }

  querys.forEach((key, value) {
    if (value == null && value is! Map) return;
    for (var element in value.keys) {
      export
          .add("export 'models/${element.toString().snakeCase}_query.dart';");
    }
  });

  path.write('''library local2dart;

export 'package:sqflite/sqflite.dart' show ConflictAlgorithm;

export 'paginations/local_meta_pagination.dart';
export 'paginations/local_pagination.dart';
export 'utils/database_instance.dart';
export 'utils/query_helper.dart';
export 'utils/bulk_insert.dart';
export 'utils/bulk_update.dart';
export 'utils/bulk_delete.dart';
${export.join('\n')}
''');
}