init property

  1. @override
dynamic Function() get init
override

Initialize your widget in init.

  • init is called in the initState method. You can use this method to perform any operations before the widget is rendered.

E.g.

get init => () async {
  await api<ApiService>((request) => request.fetchData());
  setState(() {});
};

Implementation

@override
get init => () {
      int? activeTab = data(defaultValue: {"tab-index": 0})['tab-index'];
      currentIndex = activeTab ?? 0;

      if (pages is Future Function()) {
        awaitData(perform: () async {
          _pages = await pages();
        });
      } else {
        _pages = pages();
      }
    };