-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Can we access your project?
- I give permission for members of the FlutterFlow team to access and test my project for the sole purpose of investigating this issue.
Current Behavior
I saw this error in Crashlytics:
AppMenuModel.dispose: FlutterError - LateInitializationError: Field 'expandableExpandableController1' has not been initialized
I was able to reproduce it when, from the AppMenu widget that contains explandable widget i perform a log out. I found out that FlutterFlow currently generates component controllers (e.g., ExpandableController) using Dart’s late keyword in FlutterFlowDynamicModels. Under certain navigation scenarios, Flutter calls dispose() before the widget’s initState() finishes initializing these controllers. When dispose() attempts to access the uninitialized late variable, a LateInitializationError is thrown.
This appears to be a systemic issue in the code generation for component models.
Expected Behavior
The generated code should be safe even if dispose() runs before controller initialization.
Steps to Reproduce
- Create a component or page using an Expandable widget.
- Allow FlutterFlow to generate the controller inside the model.
- Add a navigation action (for example):
- Logout
- Back navigation
- Rapid page transition
- Trigger the navigation quickly after the widget builds.
- Observe the LateInitializationError in logs.
This happens intermittently but reproducibly when navigation interrupts widget initialization.
Reproducible from Blank
- The steps to reproduce above start from a blank project.
Bug Report Code (Required)
ITFXlvHqx892rsBE15PIbcdviWIwGUALa+dI0tZ+TQ0jF5D4PbQUPsn4UBBBZ8izaH43f1X/jlMx/s7zv4fPCvknEzqbbJhFwbpAVRPPY3KhaYytC86OR3ZSL8dWfmqCyrejkR5vIthqZVYi7XGQLuytHj6Cf9qOYwx5e6fDbOY=
Visual documentation
Error.screen.recording.mov
Environment
- FlutterFlow version: latest
- Platform: MacBook Pro, Chip Apple M4
- Browser: Google Chrome - Version 138.0.7204.157 (Official Build) (arm64)
- OS: macOS Sequoia Version 15.7.3Additional Information
Instead of using a non-nullable late controller:
late ExpandableController expandableController;
FlutterFlow should generate either:
Option 1 (Preferred – null-safe)
ExpandableController? expandableController;
And dispose safely:
expandableController?.dispose();
Option 2 (Default initialization)
final ExpandableController expandableController = ExpandableController();
This guarantees initialization before dispose().