getRelativePath method
Gets the relative path from the assets directory.
Used for generating the correct asset paths in generated code.
Implementation
String getRelativePath(String assetsRoot) {
// Normalize the assets root by removing trailing slashes
final normalizedRoot = assetsRoot.replaceAll(RegExp(r'[/\\]+$'), '');
if (path.startsWith(normalizedRoot)) {
final relativePath = path.substring(normalizedRoot.length);
// Remove leading slash if present
return relativePath.replaceAll(RegExp(r'^[/\\]+'), '');
}
return path;
}