getByPathString<R> method

R getByPathString<R>(
  1. String path, {
  2. dynamic def,
})

Implementation

R getByPathString<R>(String path, {dynamic def}) {
  if (path.endsWith('/')) {
    path = path.substring(0, path.length - 1);
  }

  if (path.startsWith('/')) {
    path = path.substring(1, path.length);
  }

  List<dynamic> arr = <dynamic>[];
  for (var element in Uri(path: path).pathSegments) {
    arr.add(int.tryParse(element) ?? element);
  }
  return getByPath<R>(arr, def: def);
}