initGenerated method
Hook for code-generated initialization logic.
The generator overrides this to:
- Read every
@UserDefaultfrom disk and populateValueNotifiers (synchronous, already done by the time this returns). - Read every
@Securefield from encrypted storage and populate itsValueNotifier— genuinely awaited here soinit()(and therefore@preResolve, and therefore the rest ofmain()) never proceeds with a secure field still holding its just-constructed default. Awaiting is worth the extra cold-start latency: the alternative is a real race — an authorized request built before a token finishes loading from secure storage goes out with an emptyAuthorization: Bearerheader, 401s, and a refresh handler reading the same not-yet-loaded field treats that as "no session" and logs the user out without ever calling the network.
Implementation
@mustCallSuper
Future<void> initGenerated() async {}