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 => () {
final dynamic navData = data();
int? activeTab;
if (navData is Map && navData.containsKey('tab-index')) {
activeTab = navData['tab-index'];
}
currentIndex ??= activeTab ?? initialIndex;
// 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);
}
};