Skip to main content

Authentication Entities

The authentication module contains core domain entities that represent the business objects used throughout the authentication flow.

User

The User entity represents an authenticated user in the Softbee application. Location: lib/feature/auth/core/entities/user.dart:1

Properties

id
String
required
Unique identifier for the user
email
String
required
User’s email address
username
String
required
User’s username for display and login purposes
isVerified
bool
required
Indicates whether the user’s email has been verified
isActive
bool
required
Indicates whether the user account is active

Constructor

const User({
  required String id,
  required String email,
  required String username,
  required bool isVerified,
  required bool isActive,
});

Methods

Usage Example

// Creating a user from JSON response
final json = {
  'id': '123',
  'email': '[email protected]',
  'username': 'beekeeper',
  'is_verified': true,
  'is_active': true,
};

final user = User.fromJson(json);

// Accessing user properties
print(user.email); // Output: [email protected]
print(user.isVerified); // Output: true

// Converting user to JSON
final userJson = user.toJson();

Notes

  • The User entity is immutable (uses final fields and const constructor)
  • JSON deserialization provides default values for all fields to prevent null values
  • The JSON field is_verified maps to the Dart property isVerified (snake_case to camelCase)
  • The JSON field is_active maps to the Dart property isActive

Build docs developers (and LLMs) love