Description
In document_upload_control.dart, the _DocumentUploadControlState class instantiates a FixedExtentScrollController and a TextEditingController (documentController).
However, the State class entirely lacks a dispose() method. Because these controllers attach to native listeners, failing to dispose of them when the widget is removed from the tree creates a permanent memory leak. In a long-running production environment where operators perform dozens of registrations in a single session, these leaked controllers will compound, eventually exhausting the device's RAM and causing the Android OS to forcefully terminate the application (OOM crash).
Steps to Reproduce
- Open the application and navigate to a screen containing the
DocumentUploadControl.
- Navigate back and forth between this screen and the dashboard multiple times.
- Open the Flutter DevTools Memory Profiler.
- Observe the memory footprint continuously climbing without garbage collection reclaiming the memory allocated to the
TextEditingController and FixedExtentScrollController.
Expected Behavior
All ChangeNotifier objects and controllers must be explicitly disposed of within the State's dispose() lifecycle hook to release native resources and prevent memory leaks.
Environment
- Target File:
lib/ui/process_ui/widgets/document_upload_control.dart
Proposed Solution
Implement the dispose() override in _DocumentUploadControlState and explicitly call .dispose() on both documentController and scrollController.
Description
In
document_upload_control.dart, the_DocumentUploadControlStateclass instantiates aFixedExtentScrollControllerand aTextEditingController(documentController).However, the State class entirely lacks a
dispose()method. Because these controllers attach to native listeners, failing to dispose of them when the widget is removed from the tree creates a permanent memory leak. In a long-running production environment where operators perform dozens of registrations in a single session, these leaked controllers will compound, eventually exhausting the device's RAM and causing the Android OS to forcefully terminate the application (OOM crash).Steps to Reproduce
DocumentUploadControl.TextEditingControllerandFixedExtentScrollController.Expected Behavior
All
ChangeNotifierobjects and controllers must be explicitly disposed of within the State'sdispose()lifecycle hook to release native resources and prevent memory leaks.Environment
lib/ui/process_ui/widgets/document_upload_control.dartProposed Solution
Implement the
dispose()override in_DocumentUploadControlStateand explicitly call.dispose()on bothdocumentControllerandscrollController.