use the basename
function from the dart path library:
import 'package:path/path.dart';
File file = new File("/dir1/dir2/file.ext");
String basename = basename(file.path);
# file.ext
Get tutorials, Flutter news and other exclusive content delivered to your inbox. Join 1000+ growth-oriented Flutter developers subscribed to the newsletter