i have code like this from the internet, and my is not working:
class _StartingAnimationState extends State<StartingAnimation>{
@override
void initState() {
Future.delayed(Duration(seconds: 4),(){
Navigator.push(context, MaterialPageRoute(builder: (context) {
return mainWindow();
}));
});
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: SizedBox(height: 300,width: 300, child: Lottie.asset("assets/lottie/login.json")),
);
}
}
I got error:
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Navigator operation requested with a context that does not include a Navigator.
and
The context used to push or pop routes from the Navigator must be that of a widget that is a descendant of a Navigator widget.
I want my program to show animation for some time, and then navigate to other screen