Permission class final
An immutable, namespaced permission token.
Permissions follow the format <resource>:<action>, e.g.:
'posts:read''posts:write''posts:*'(wildcard — grants all actions on the resource)
final perm = Permission.read('posts');
print(perm.key); // 'posts:read'
print(perm.resource); // 'posts'
print(perm.action); // 'read'
print(perm.isWildcard); // false
- Annotations
Constructors
- Permission(String key)
-
Creates a Permission from a raw
keystring.const - Permission.all(String resource)
-
Returns a wildcard permission for
resource, e.g.'posts:*'.const - Permission.delete(String resource)
-
Returns a delete permission for
resource, e.g.'posts:delete'.const - Permission.read(String resource)
-
Returns a read permission for
resource, e.g.'posts:read'.const - Permission.write(String resource)
-
Returns a write permission for
resource, e.g.'posts:write'.const
Properties
- action → String
-
The action segment, e.g.
'read'from'posts:read'.no setter - hashCode → int
-
The hash code for this object.
no setteroverride
- isWildcard → bool
-
Whether this is a wildcard permission (action is
'*').no setter - key → String
-
The raw permission key, e.g.
'posts:read'.final - resource → String
-
The resource segment, e.g.
'posts'from'posts:read'.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override