Flutter how to remove file extension when i need to put file name into variable

Viewed 885

I use p.basename from flutter path library to get file name, but i got it with extension, how to remove extension? also to get path I use getApplicationDocumentsDerectory from path_provider library

File newFile = File(filepath);
String name = p.basename(newFile.path);

this is code I use to get file name

1 Answers

You just use 'basenameWithoutExtension' method like basename.

enter image description here

File newFile = File(filepath);
String name = p.basename(newFile.path);
String nameWithoutExtension = p.basenameWithoutExtension(newFile.path);
Related