goRoute property

String goRoute
inherited

the path to be used for GoRoute.path

Implementation

String get goRoute {
  final path = _path;
  if (path == null) {
    final param = _param;
    assert(param != null, 'Param cannot be null when path is null');

    if (!RegExp(r'^\w+$').hasMatch(param!)) {
      throw ArgumentError(
        'Param must be alphanumeric and cannot contain special characters',
      );
    }

    return ':$param';
  }

  final cleanPath = _clean(path);

  final parent = _parent;
  var start = '/';
  if (parent != null && parent._segments.isNotEmpty) {
    start = '';
  }

  var param = '';
  if (_param != null) {
    param = '/:$_param';
  }

  return '$start$cleanPath$param';
}