Skip to content

Instantly share code, notes, and snippets.

@codinghivedev
Last active July 16, 2020 02:17
Show Gist options
  • Save codinghivedev/f0fb53de9524264f5311e2e80ad29c22 to your computer and use it in GitHub Desktop.
Save codinghivedev/f0fb53de9524264f5311e2e80ad29c22 to your computer and use it in GitHub Desktop.
To get file name in Flutter
import 'package:path/path.dart' as path;
class AppUtil{
static Future<String> getFileNameWithExtension(File file)async{
if(await file.exists()){
//To get file name without extension
//path.basenameWithoutExtension(file.path);
//return file with file extension
return path.basename(file.path);
}else{
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment