appendLocatorFeature method

void appendLocatorFeature(
  1. String pathFeature,
  2. String featureName,
  3. String pageName,
  4. String className,
  5. String methodName,
)

Implementation

void appendLocatorFeature(
  String pathFeature,
  String featureName,
  String pageName,
  String className,
  String methodName,
) {
  final path = join(pathFeature, 'lib');
  String data = File(join(path, 'locator.dart')).readAsStringSync();

  data = data.replaceAll(RegExp(r'\n?void\s\w+\(\)\s{', multiLine: true),
      '''import '$pageName/locator.dart';

void setupLocatorFeature${featureName.pascalCase}() {''');

  data = data.replaceAll(
      RegExp(r'}\n$', multiLine: true), '''  setupLocator$className();
}''');

  join(path, 'locator.dart').write(data);

  StatusHelper.generated(join(path, 'locator.dart'));
}