routeGuardStub function

String routeGuardStub(
  1. ReCase rc
)

This stub is used to create a Route Guard class in the /routes/guards/ directory.

Implementation

String routeGuardStub(ReCase rc) => '''
import 'package:nylo_framework/nylo_framework.dart';

/* ${rc.pascalCase} Route Guard
|-------------------------------------------------------------------------- */

class ${rc.pascalCase}RouteGuard extends NyRouteGuard {
  ${rc.pascalCase}RouteGuard();

  @override
  onRequest(PageRequest pageRequest) async {
    // example
    // if (Auth.isAuthenticated() == false) {
    //    return redirect(HomePage.path);
    // }
    //
    // helpers
    // data = will give you access to the data passed to the route
    // context = will give you access to the BuildContext
    return pageRequest;
  }
}
''';