onInit method
Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.
Implementation
@override
void onInit() {
arguments = NavUtils.arguments as DashboardViewArguments?;
tabController = TabController(length: 2, vsync: this);
if ((arguments?.didMissedCallNotificationLaunchApp).checkNull()) {
tabController?.animateTo(1);
}
tabController?.animation?.addListener(() {
LogMessage.d("DefaultTabController", "${tabController?.index}");
// Current animation value. It ranges from 0 to (tabsCount - 1)
final animationValue = tabController?.animation!.value;
LogMessage.d("animationValue", "$animationValue");
// Simple rounding gives us understanding of what tab is showing
final currentTabIndex = animationValue?.round();
LogMessage.d("currentTabIndex animation listener", "$currentTabIndex");
currentTab(currentTabIndex);
// currentOffset equals 0 when tabs are not swiped
// currentOffset ranges from -0.5 to 0.5
final currentOffset = currentTabIndex! - animationValue!;
for (int i = 0; i < tabsCount; i++) {
if (i == currentTabIndex) {
// For current tab bringing currentOffset to range from 0.0 to 1.0
tabScales[i] = (0.5 - currentOffset.abs()) / 0.5;
} else {
// For other tabs setting scale to 0.0
tabScales[i] = 0.0;
}
}
});
//The above animation listener is called multiple time till the animation gets over, this listener is called minimal time when compared to above
tabController?.addListener(() {
LogMessage.d("currentTabIndex default listener", "$currentTab");
clearAllChatSelection();
if (currentTab.value == 1) {
markAllUnreadMissedCallsAsRead();
}
});
pageNumber = 1;
Mirrorfly.syncCallLogs().then((isSuccess) {
debugPrint("#MirrorflyCall syncCallLogs isSuccess $isSuccess");
});
super.onInit();
}