Skip to content

Instantly share code, notes, and snippets.

@mohSleem
Last active March 12, 2019 16:43
Show Gist options
  • Save mohSleem/4f72d5f1018195ae88e37c46707e461e to your computer and use it in GitHub Desktop.
Save mohSleem/4f72d5f1018195ae88e37c46707e461e to your computer and use it in GitHub Desktop.
flutter splash screen
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