Skip to content

Seal FileSystemEntity. #52273

Closed
Closed

Description

Image for: Description

Similar to #52027 and #51912, could FileSystemEntity also be sealed so that functions like:

Z matchFileSystemEntity<Z>({
  required final FileSystemEntity entity,
  required final Z Function(Directory) directory,
  required final Z Function(File) file,
  required final Z Function(Link) link,
}) {
  if (entity is Directory) {
    return directory(entity);
  } else if (entity is File) {
    return file(entity);
  } else if (entity is Link) {
    return link(entity);
  } else {
    throw Exception(
      "Invalid state. " + entity.toString() + " was expected to be a directory, file or link.",
    );
  }
}

can be replaced with exhaustive switches?

Metadata

Image for: Metadata

Metadata

Image for: Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.library-iotype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Image for: Issue actions