hasRole method

bool hasRole(
  1. String role
)

Check if the current user has a specific role

Example:

if (db.auth.hasRole('admin')) {
  print('User is an admin');
}

Implementation

bool hasRole(String role) {
  if (_user == null) return false;
  final roles = _user!.roles ?? [];
  return roles.contains(role);
}