createPostLocator method
Implementation
void createPostLocator(String pathPage, String pageName, String apiName) {
String data = File(join(pathPage, 'locator.dart')).readAsStringSync();
final bloc = find(
'*',
recursive: false,
includeHidden: false,
workingDirectory: join(pathPage, 'presentation', 'bloc'),
types: [Find.directory],
)
.toList()
.map((e) =>
'${e.replaceAll('${join(pathPage, 'presentation', 'bloc')}$separator', '').camelCase}Bloc: locator()')
.join(',');
data = data.replaceAll(
RegExp(r"\w*Cubit\((([\w,:\s]*(\(\))?)+)?\)"),
'${pageName.pascalCase}Cubit($bloc,)',
);
data = data.replaceAll(RegExp(r';?(\s+)?}', multiLine: true), ''';}''');
join(pathPage, 'locator.dart').write(data);
StatusHelper.generated(join(pathPage, 'locator.dart'));
}