modal route inside initstate flutter
var = args;
_yourFunction(args) async {
// whatever you want to do
}
@override
void initState() {
super.initState();
// future that allows us to access context. function is called inside the future
// otherwise it would be skipped and args would return null
Future.delayed(Duration.zero, () {
setState(() => args = ModalRoute.of(context).settings.arguments);
_yourFunction(args);
});
}