onInit method
Lifecycle method called immediately after controller creation.
Override this to perform early initialization tasks that don't require the widget tree to be built yet. This is called synchronously during controller construction.
Always call super.onInit() when overriding.
Example:
@override
void onInit() {
super.onInit();
// Initialize reactive variables
user.value = loadCachedUser();
// Setup listeners
count.addListener((value) => saveToStorage(value));
}
Implementation
@mustCallSuper
void onInit() {
Logger.info('onInit of $runtimeType called', tag: 'ReactiveController');
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
onReady();
});
}