Problem: CupertinoTabScaffold tab content does not refresh after closing new screen from CupertinoPageRoute
App: There is a list of data in a Listview. I open one data set and remove the favourite status (checked=false). I close the data set and the listview should refresh (FutureBuilder to an SQL database).
Details: I've got a Flutter App with two layouts (Material and Cupertino). In each layout i have four tabs and the content widgets are the same. On the Cupertino App every tab consists of a CupertinoPageScaffold. When i press on an element it navigates to a new screen with CupertinoPageRoute. After closing the CupertinoPageRoute the tab content is not refreshing. The tab content is refreshing when i switch between the four tabs.
If one CupertinoPageRoute is open and i open a new one from here and close it again then the content of the opened CupertinoPageScaffold is refreshing. The data is refreshing without a callback etc., just by calling the future (i think).
Means there should be a problem with the CupertinoTabScaffold. There is no problem on the Material App. The tab contents of the Material App are refreshing when closing a MaterialPageRoute.
Question: Is there a problem at this position? Do you have the same issue or maybe a solution or workaround?
Code: My code is not really representative so i will create a new clean project for you. please confirm if code is necessary.
What i tried: I tried a lot of solutions from the internet like callbacks, setState, .then, .whencomplete for the route. nothing seems to work.
Thank you in advance.
EDIT 03.10.2021: the tabcontroller with SingleTickerProviderStateMixin reloads the open tab when i open or close an new screen. if i just use DefaultTabController Widget than it doesn't. So i have to edit the CupertinoTabController.
class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
late TabController _tabController;
final CupertinoTabController _cuptabController = CupertinoTabController();
Future<void> _refreshdata() async {
downloadJSON1();
setState(() {
});
}
callback() {
_refreshdata();
}
@override
void initState() {
_refreshdata();
super.initState();
_tabController = TabController(vsync: this, length: 2, initialIndex: 0);
_cuptabController.index = widget.starttab;
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
...
}