resolvedFileName method

String? resolvedFileName()

Resolves and returns the file name from the _resolvedUrl if available.

This method parses the _resolvedUrl as a URI and extracts the last segment of the path as the file name. If the file name starts with _name, it appends the file name to _name with a hyphen (-) separator and returns the result.

Implementation

String? resolvedFileName() {
  if (_resolvedUrl == null) return null;

  final uri = Uri.parse(_resolvedUrl!);
  final pathSegments = uri.pathSegments;

  if (pathSegments.isEmpty) return null;

  String fileName = pathSegments.last;
  if (!fileName.startsWith(_name)) {
    return '$_name-$fileName';
  }

  return fileName;
}