routerGo method

  1. @override
Future<Either<Failure, Unit>> routerGo(
  1. String page
)
override

Implementation

@override
Future<Either<Failure, Unit>> routerGo(String page) {
  return trying(() async {
    final navigationPath = 'lib/service/navigation/navigation.service.dart';
    final routesPath = 'lib/service/navigation/_routers.dart';
    final routeNamesPath = 'lib/service/navigation/_route_names.dart';

    final navigationContent = await dataSource.navigationService(page);
    final routesContent = await dataSource.routes(page);
    final routeNamesContent = await dataSource.routeNames(page);

    final result = await Future.wait([
      trying(
        () => fileManager.generatePath(navigationPath, printError: true),
      ),
      trying(
        () => fileManager.generatePath(routesPath, printError: true),
      ),
      trying(
        () => fileManager.generatePath(routeNamesPath, printError: true),
      ),
    ]);

    if (result.every((element) => element.isRight())) {
      await fileManager.write(navigationPath, navigationContent);
      await fileManager.write(routesPath, routesContent);
      await fileManager.write(routeNamesPath, routeNamesContent);
    }
  });
}