onInit method
override
Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.
Implementation
@override
void onInit() {
Log.debug('onInit', '$runtimeType');
if (PlatformUtils.isMobile && !PlatformUtils.isWeb) {
BackButtonInterceptor.add(_onBack, ifNotYetIntercepted: true);
}
buttons.value = _toButtons(
_settingsRepository?.applicationSettings.value?.pinnedActions,
);
_buttonsWorker?.dispose();
_buttonsWorker = ever(buttons, (List<ChatButton> list) {
_settingsRepository?.setPinnedActions(
list.map((e) => e.runtimeType.toString()).toList(),
);
});
String route = router.route;
_routesWorker?.dispose();
_routesWorker = ever(router.routes, (routes) {
if (router.route != route) {
_moreEntry?.remove();
_moreEntry = null;
}
});
_repliesSubscription?.cancel();
_repliesSubscription = replied.listen((_) => onChanged?.call());
_attachmentsSubscription?.cancel();
_attachmentsSubscription = attachments.listen((_) => onChanged?.call());
_donationSubscription?.cancel();
_donationSubscription = donation.listen((_) => onChanged?.call());
_editedSubscription?.cancel();
_editedSubscription = edited.listen((item) {
if (item != null) {
field.text = item.text?.val ?? '';
attachments.value = item.attachments
.map((e) => MapEntry(GlobalKey(), e))
.toList();
replied.value = item.repliesTo
.map((e) => e.original)
.nonNulls
.map((e) => Rx(e))
.toList();
} else {
field.text = '';
attachments.clear();
replied.clear();
}
onChanged?.call();
});
super.onInit();
}