init property
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;
// Store current tab index and total pages count for navigation helpers
Backpack.instance.save('${stateName}_current_tab', currentIndex);
if (pages is Future Function()) {
awaitData(perform: () async {
_pages = await pages();
Backpack.instance.save('${stateName}_total_pages', _pages.length);
});
} else {
_pages = pages();
Backpack.instance.save('${stateName}_total_pages', _pages.length);
}
};