I was trying to get file extension with dart code as this,
var url = downloadUrl.toString();
String fileExtension = '';
String fileName = path.split("\/").last;
bool fileExt = false;
for (var characterUrl = 0;
characterUrl < fileName.length;
characterUrl++) {
if (String.fromCharCode(fileName.codeUnitAt(characterUrl)) == '.' && !fileExt) {
fileExt = true;
}
if (fileExt) {
fileExtension += String.fromCharCode(fileName.codeUnitAt(characterUrl));
}
}
When having a file named as:
eg: Screenshot_2021-06-10_co.com.app.jpg
It returns me:
".com.app.jpg"
But I would like just to get the .jpg
In other file names it works perfectly.