toRoutePath function

String toRoutePath({
  1. required String title,
})

Converts the string title to route path.

Implementation

String toRoutePath({required String title}) {
  String routePath;
  String string = getStringFromTextWidget(title);
  string = string.replaceAll(RegExp(r'[^\w\s]+'), '').toLowerCase();
  string.contains(' ')
      ? routePath = string.replaceAll(" ", "-")
      : routePath = string;
  return "/$routePath";
}