A tiny path helper: join('/') glues a list of segments into one string, and split('/') reverses it. Taking segments.last pulls the final piece, which is the file name in a typical path.

Program

Play the program to join three segments into a path and pull the file name back out.

path_join_lite.dart
void main() {
  var parts = ['logs', '2026', 'app.txt'];
  var path = parts.join('/');
  var segments = path.split('/');
  var name = segments.last;
  print('$path | $name');
}
join `parts.join('/')` glues a list of segments into one path string.
split `path.split('/')` reverses the join, returning the original segments.
last `segments.last` returns the final element, which is the file name in a typical path.