file method

File file(
  1. String filePath
)

Returns a File within the Directory

Directory androidDir = Directory('flutter-app/android');
File manifestFile = androidDir.file("app/src/main/AndroidManifest.xml");

Implementation

File file(String filePath) {
  final sb = StringBuffer(absolute.path);
  final path = sb.toString();
  if (!path.endsWith(Platform.pathSeparator) &&
      !filePath.startsWith(Platform.pathSeparator)) {
    // no separator between dir and filePath
    sb.write(Platform.pathSeparator);
  }
  if (path.startsWith(Platform.pathSeparator) &&
      filePath.startsWith(Platform.pathSeparator)) {
    // joining would cause a double //
    final path = filePath.replaceFirst(Platform.pathSeparator, '');
    sb.write(path);
  } else {
    sb.write(filePath);
  }
  return File(sb.toString());
}