hasFlag method

bool hasFlag(
  1. StorageItemTypes flag
)

Determines whether one or more bit fields are set in the current enum value.

final fileAttributes = FileAttributes.readOnly | FileAttributes.archive;
fileAttributes.hasFlag(FileAttributes.readOnly)); // `true`
fileAttributes.hasFlag(FileAttributes.temporary)); // `false`
fileAttributes.hasFlag(
    FileAttributes.readOnly | FileAttributes.archive)); // `true`

Implementation

bool hasFlag(StorageItemTypes flag) {
  if (value != 0 && flag.value == 0) return false;
  return value & flag.value == flag.value;
}