feat: Centralized Error Handling & Crash Fixes

This commit is contained in:
2026-02-11 18:52:23 +05:30
parent ea06510474
commit c1112ac01c
51 changed files with 2104 additions and 960 deletions

View File

@@ -1,4 +1,5 @@
import 'dart:developer' as developer;
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:krow_domain/krow_domain.dart';
@@ -118,3 +119,21 @@ mixin BlocErrorHandler<S> {
}
}
}
/// Mixin to safely add events to a [Bloc] by checking if it is closed.
///
/// This prevents the [StateError] "Cannot add new events after calling close".
mixin SafeBloc<E, S> on Bloc<E, S> {
@override
void add(E event) {
if (!isClosed) {
super.add(event);
} else {
developer.log(
'SafeBloc: Attempted to add event $event to closed Bloc $runtimeType',
name: runtimeType.toString(),
level: 900, // Warning level
);
}
}
}

View File

@@ -65,27 +65,27 @@ class StaffPaths {
/// Home tab - the main dashboard for staff.
///
/// Displays shift cards, quick actions, and notifications.
static const String home = '/worker-main/home';
static const String home = '/worker-main/home/';
/// Shifts tab - view and manage shifts.
///
/// Browse available shifts, accepted shifts, and shift history.
static const String shifts = '/worker-main/shifts';
static const String shifts = '/worker-main/shifts/';
/// Payments tab - view payment history and earnings.
///
/// Access payment history, earnings breakdown, and tax information.
static const String payments = '/worker-main/payments';
static const String payments = '/worker-main/payments/';
/// Clock In tab - clock in/out functionality.
///
/// Time tracking interface for active shifts.
static const String clockIn = '/worker-main/clock-in';
static const String clockIn = '/worker-main/clock-in/';
/// Profile tab - staff member profile and settings.
///
/// Manage personal information, documents, and preferences.
static const String profile = '/worker-main/profile';
static const String profile = '/worker-main/profile/';
// ==========================================================================
// SHIFT MANAGEMENT
@@ -113,22 +113,22 @@ class StaffPaths {
///
/// Collect basic personal information during staff onboarding.
static const String onboardingPersonalInfo =
'/worker-main/onboarding/personal-info';
'/worker-main/onboarding/personal-info/';
/// Emergency contact information.
///
/// Manage emergency contact details for safety purposes.
static const String emergencyContact = '/worker-main/emergency-contact';
static const String emergencyContact = '/worker-main/emergency-contact/';
/// Work experience information.
///
/// Record previous work experience and qualifications.
static const String experience = '/worker-main/experience';
static const String experience = '/worker-main/experience/';
/// Attire and appearance preferences.
///
/// Record sizing and appearance information for uniform allocation.
static const String attire = '/worker-main/attire';
static const String attire = '/worker-main/attire/';
// ==========================================================================
// COMPLIANCE & DOCUMENTS
@@ -137,12 +137,12 @@ class StaffPaths {
/// Documents management - upload and manage required documents.
///
/// Store ID, work permits, and other required documentation.
static const String documents = '/worker-main/documents';
static const String documents = '/worker-main/documents/';
/// Certificates management - professional certifications.
///
/// Manage professional certificates (e.g., food handling, CPR, etc.).
static const String certificates = '/worker-main/certificates';
static const String certificates = '/worker-main/certificates/';
// ==========================================================================
// FINANCIAL INFORMATION
@@ -151,12 +151,12 @@ class StaffPaths {
/// Bank account information for direct deposit.
///
/// Manage banking details for payment processing.
static const String bankAccount = '/worker-main/bank-account';
static const String bankAccount = '/worker-main/bank-account/';
/// Tax forms and withholding information.
///
/// Manage W-4, tax withholding, and related tax documents.
static const String taxForms = '/worker-main/tax-forms';
static const String taxForms = '/worker-main/tax-forms/';
/// Form I-9 - Employment Eligibility Verification.
///
@@ -171,7 +171,7 @@ class StaffPaths {
/// Time card - view detailed time tracking records.
///
/// Access detailed time entries and timesheets.
static const String timeCard = '/worker-main/time-card';
static const String timeCard = '/worker-main/time-card/';
// ==========================================================================
// SCHEDULING & AVAILABILITY
@@ -180,7 +180,7 @@ class StaffPaths {
/// Availability management - set working hours preferences.
///
/// Define when the staff member is available to work.
static const String availability = '/worker-main/availability';
static const String availability = '/worker-main/availability/';
// ==========================================================================
// ADDITIONAL FEATURES (Placeholders)

View File

@@ -11,6 +11,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_bloc: ^8.1.0
design_system:
path: ../design_system
equatable: ^2.0.8