Response Lifecycle
HTML workbooks collect user data with automatic response saving via Flutter integration. All interactive workbooks follow these specifications for consistent behavior and data integrity.
Workbook Load Sequence
- HTML Loads — Workbook HTML is rendered in a WebView
- Flutter Channel Ready — JavaScript receives
onFlutterChannelReadycallback - Check Response Exists — Sends
checkResponseExistsmessage to Flutter - Load if Found — If previous responses exist, loads them via
loadWorkbookResponse - Populate Form — Saved data is populated into form fields
- Enable Auto-Save — Event listeners attached to all form elements
First Time User Flow
- HTML displays normal entry form
- User fills out data
- As user fills out sections, responses are auto-saved (2-second debounce)
- Data sent to Flutter via channel
- Flutter saves to:
AppData/JSONs/User_Workbook_Responses/ - Status banner shows real-time save status
Returning User Flow
- HTML checks for existing responses
- If found: automatically load data into form
- Edit mode: detect when data is changed
- Auto-save: update same response file (don’t create new)
Auto-Save Mechanism
The auto-save uses a 2-second debounce timer:
triggerAutoSave()is called on any form change- Clears any existing timer and shows “Editing…” status
- After 2 seconds of inactivity, triggers
saveWorkbook() saveInProgressflag prevents concurrent saves
AUTO_SAVE_DELAY = 2000ms (2 seconds after user stops typing)
Status Indicator States
| State | Display | Description |
|---|---|---|
| idle | “Responses are auto-saved” | Default state |
| typing | “Editing…” | User is actively changing data |
| saving | “Saving…” | Save request sent to Flutter |
| saved | “Saved” | Save confirmed (shows for 2s then returns to idle) |
| error | “Save failed - will retry” | Save failed (shows for 3s then returns to idle) |
Key Concept
The collectWorkbookData() function gathers ALL form elements regardless of type (text inputs, checkboxes, radio buttons, textareas, etc.), and triggerAutoSave() is attached to ALL interactive elements so any change triggers the save after 2 seconds.
Flutter only handles saving and loading JSON responses — all form interactions and auto-save logic are managed by the HTML workbook itself.