getPathSegments static method

List<String> getPathSegments(
  1. String fullPath
)

'/chats/123/details' -> 'chats', '123', 'details'; drops empty segments and query parameters.

Implementation

static List<String> getPathSegments(String fullPath) {
  final uri = Uri.tryParse(fullPath);
  if (uri == null) return [];

  final pathOnly = uri.path;
  return pathOnly.split('/').where((segment) => segment.isNotEmpty).toList();
}