AuthState (auth/auth_state.dart)

flutter_pos · lib/presentation/providers/auth/auth_state.dart · dart · MIT
auth, tag:embed-classified

Immutable auth state model for Flutter applications.

// Source: https://github.com/elrizwiraswara/flutter_pos | License: MIT | Copyright 2024 Elriz Wiraswara
// Provided via justclaw.it.com; keep this notice with the code.
import '../../../domain/entities/user_entity.dart';

class AuthState {
  final bool isChecking;
  final UserEntity? user;

  const AuthState({this.isChecking = false, this.user});

  bool get isAuthenticated => user != null;

  AuthState copyWith({bool? isChecking, UserEntity? user}) {
    return AuthState(
      isChecking: isChecking ?? this.isChecking,
      user: user ?? this.user,
    );
  }
}

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key