Created
June 20, 2018 09:52
-
-
Save ShanmugavelGK/23800fb531a39b3241db6084200fd7a2 to your computer and use it in GitHub Desktop.
SplashScreen with animate logo
This file contains 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
List<CameraDescription> cameras; | |
Future<Null> main() async { | |
cameras = await availableCameras(); | |
runApp(new MaterialApp( | |
debugShowCheckedModeBanner: false, | |
theme: new ThemeData( | |
brightness: Brightness.light, | |
primaryColor: Colors.green, | |
secondaryHeaderColor: Colors.green, | |
accentColor: Color(0xFF73bc42), | |
), | |
home: new SplashScreen(), | |
routes: <String, WidgetBuilder>{ | |
'/screens/LoginScreen': (BuildContext context) => new LoginScreen(), | |
'/screens/SignUpScreen': (BuildContext context) => new SignUpBasicScreen(cameras) | |
}, | |
)); | |
} | |
class SplashScreen extends StatefulWidget { | |
@override | |
_SplashScreenState createState() => new _SplashScreenState(); | |
} | |
class _SplashScreenState extends State<SplashScreen> | |
with SingleTickerProviderStateMixin { | |
AnimationController _logoAnimationController; | |
Animation<double> _logoAnimation; | |
startTime() async { | |
var _duration = new Duration(seconds: 3); | |
return new Timer(_duration, navigationPage); | |
} | |
void navigationPage() { | |
Navigator.of(context).pushReplacementNamed('/screens/LoginScreen'); | |
} | |
@override | |
void initState() { | |
super.initState(); | |
_logoAnimationController = new AnimationController( | |
vsync: this, duration: new Duration(milliseconds: 300)); | |
_logoAnimation = new CurvedAnimation( | |
parent: _logoAnimationController, curve: Curves.easeOut); | |
_logoAnimation.addListener(() => this.setState(() {})); | |
_logoAnimationController.forward(); | |
startTime(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
backgroundColor: Colors.white, | |
body: new Stack( | |
fit: StackFit.expand, | |
children: <Widget>[ | |
new Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: <Widget>[ | |
new Image.asset('images/ic_logo_name.png', | |
width: _logoAnimation.value * 200.0, | |
height: _logoAnimation.value * 100.0) | |
], | |
) | |
], | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment