entity method

  1. @override
Future<Either<Failure, Unit>> entity({
  1. required String feature,
  2. required String entity,
})
override

Implementation

@override
Future<Either<Failure, Unit>> entity({
  required String feature,
  required String entity,
}) {
  return trying(() async {
    final path = 'lib/features/$feature/entity/$entity.entity.dart';
    final entitiesPath = 'lib/features/$feature/entity/entities.dart';
    await fileManager.generatePath(path);
    try {
      await fileManager.generatePath(entitiesPath);
      await fileManager.write(entitiesPath, await dataSource.entities());
    } catch (_) {}
    final content = await dataSource.entity(entity);
    await fileManager.write(path, content);
    await fileManager.write(
      entitiesPath,
      'part \'$entity.entity.dart\';\n',
      mode: FileMode.append,
    );
  });
}