Last active
March 12, 2019 16:43
-
-
Save mohSleem/4f72d5f1018195ae88e37c46707e461e to your computer and use it in GitHub Desktop.
flutter splash screen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() async{ | |
runApp( | |
new MaterialApp( | |
title: "weather app", | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData.light(), | |
home: new SplashScreen(), | |
routes: <String, WidgetBuilder>{ | |
'/HomePage': (BuildContext context) => HomePage(), | |
}, | |
), | |
); | |
} | |
class SplashScreen extends StatefulWidget { | |
@override | |
_SplashScreenState createState() => new _SplashScreenState(); | |
} | |
class _SplashScreenState extends State<SplashScreen> { | |
startTime() async { | |
var _duration = new Duration(seconds: 2); | |
return new Timer(_duration, navigationPage); | |
} | |
void navigationPage() { | |
Navigator.of(context).pushReplacementNamed('/HomePage'); | |
} | |
@override | |
void initState() { | |
super.initState(); | |
startTime(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
body: Container( | |
width: MediaQuery.of(context).size.width, | |
height: MediaQuery.of(context).size.height, | |
child: new Image.asset('الصورة من ملف الاسيت',fit: BoxFit.cover,), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment