isAllowedEntityType method
Implementation
bool? isAllowedEntityType(Type type) {
if (isInnocuous) return null;
if (entityType == type) {
if (ruleType == EntityAccessRuleType.allow) {
// If allows a field also allows a type (not checking `entityFields`):
return true;
} else if (ruleType == EntityAccessRuleType.block) {
final entityFields = this.entityFields;
var fieldRule = entityFields != null && entityFields.isNotEmpty;
// If blocks a field it's not fully blocking a type:
if (fieldRule) {
return true;
}
// If there's NO field rule, the type is being blocked:
else {
return false;
}
}
}
final rules = this.rules;
if (rules == null || rules.isEmpty) return null;
for (var r in rules.reversed) {
var allowed = r.isAllowedEntityType(type);
if (allowed != null) return allowed;
}
return null;
}