onInit method

  1. @override
void onInit()
override

Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.

Implementation

@override
void onInit() {
  tabController = TabController(
      initialIndex:
          GetStorage().read(_StorageConstants().isTenRecitations) ?? 0,
      length: 2,
      vsync: this);

  _lastTabIndexNotified = tabController.index;

  _tabControllerListener = () {
    // حدّث مرة واحدة لكل تغيّر فعلي بالـ index.
    final idx = tabController.index;
    if (idx == _lastTabIndexNotified) return;
    _lastTabIndexNotified = idx;
    GetStorage().write(
      _StorageConstants().isTenRecitations,
      idx,
    );
    update(['word_info_data']);
    QuranCtrl.instance.update();
  };
  tabController.addListener(_tabControllerListener!);
  super.onInit();
}