Skip to content

UnsupportedError crash due to fixed-length List.empty() initialization in Service implementations #1049

@vibhutomer

Description

@vibhutomer

Description

Across several service implementations (e.g., BiometricsServiceImpl, ProcessSpecServiceImpl), lists are initialized using List.empty() inside try-catch blocks as fallback values when an API call fails.

In Dart, List.empty() defaults to growable: false. This creates a strictly fixed-length list of size 0. If the UI layer or state management providers later attempt to append items to these lists using .add() or .addAll(), the application will immediately crash with an UnsupportedError (Cannot add to a fixed-length list).

Steps to Reproduce

  1. Trigger a method that returns List.empty() on failure (e.g., getBiometrics or getNewProcessSpec).
  2. Simulate a network or platform exception so the catch block executes.
  3. Have the consuming UI provider attempt to append a new item to the returned list (list.add(newItem)).
  4. Observe the runtime crash and UnsupportedError in the console.

Expected Behavior

Fallback empty lists should be growable so that consuming UI layers can safely interact with them without causing runtime exceptions.

Environment

  • Target Files: biometrics_service_impl.dart, process_spec_service_impl.dart, document_category_impl.dart, etc.

Proposed Solution

Replace all instances of List.empty() with the standard growable list literal [] (or explicitly use List.empty(growable: true)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions