How to show splash screen in flutter for 3 seconds and then go next my login screen.
I have tried.countdowntimer but import is unresolved
import \'pack
The cleanest approach without adding explicit timers.
Use Time based SplashScreen
.
class TimeBasedSplash extends State{
@override
Widget build(BuildContext context) {
return new SplashScreen(
seconds: 10,
navigateAfterSeconds: new HomeScreen(),// Where to navigate after 10 secs
image: new Image.asset('assets/images/flutter_logo.png'),
photoSize: 200,
loaderColor: Colors.white,
styleTextUnderTheLoader : const TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold, color: Colors.white),
loadingText: new Text('Loading...'),
gradientBackground: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.lightBlue,
Colors.indigo
],
),
);
}
}
In main class
void main(){
runApp(new MaterialApp(
home: new MyApp(),
));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State {
@override
Widget build(BuildContext context) {
return new TimeBasedSplash().build(context);
}
}