feature method
Implementation
@override
Future<Either<Failure, Unit>> feature(String name) async {
return trying(() async {
final featurePath = 'lib/features/$name/$name.repository.dart';
final featureImplPath = 'lib/features/$name/$name.impl.repository.dart';
final featureDatasourcePath = 'lib/features/$name/$name.datasource.dart';
final featureContent = await dataSource.repository(name);
final featureImplContent = await dataSource.repositoryImpl(name);
final featureDatasourceContent = await dataSource.dataSource(name);
final result = await Future.wait([
trying(
() => fileManager.generatePath(featurePath, printError: true),
),
trying(
() => fileManager.generatePath(featureImplPath, printError: true),
),
trying(
() =>
fileManager.generatePath(featureDatasourcePath, printError: true),
),
]);
if (result.every((element) => element.isRight())) {
await fileManager.write(featurePath, featureContent);
await fileManager.write(featureImplPath, featureImplContent);
await fileManager.write(
featureDatasourcePath,
featureDatasourceContent,
);
}
});
}