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
- Trigger a method that returns
List.empty() on failure (e.g., getBiometrics or getNewProcessSpec).
- Simulate a network or platform exception so the
catch block executes.
- Have the consuming UI provider attempt to append a new item to the returned list (
list.add(newItem)).
- 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)).
Description
Across several service implementations (e.g.,
BiometricsServiceImpl,ProcessSpecServiceImpl), lists are initialized usingList.empty()insidetry-catchblocks as fallback values when an API call fails.In Dart,
List.empty()defaults togrowable: 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 anUnsupportedError (Cannot add to a fixed-length list).Steps to Reproduce
List.empty()on failure (e.g.,getBiometricsorgetNewProcessSpec).catchblock executes.list.add(newItem)).UnsupportedErrorin 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
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 useList.empty(growable: true)).