-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completed issue #164 ==> Completed splash screen
- Loading branch information
Showing
4 changed files
with
99 additions
and
2 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import 'dart:async'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:learn/landing_page.dart'; | ||
|
||
class SplashScreen extends StatefulWidget { | ||
const SplashScreen({super.key}); | ||
|
||
@override | ||
State<SplashScreen> createState() => _SplashScreenState(); | ||
} | ||
|
||
class _SplashScreenState extends State<SplashScreen> with SingleTickerProviderStateMixin { | ||
late AnimationController _controller; | ||
late Animation<double> _fadeInAnimation; | ||
late Animation<double> _scaleAnimation; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
_controller = AnimationController( | ||
duration: const Duration(seconds: 2), | ||
vsync: this, | ||
); | ||
|
||
_fadeInAnimation = Tween<double>(begin: 0.3, end: 1.0).animate( | ||
CurvedAnimation(parent: _controller, curve: Curves.easeIn), | ||
); | ||
|
||
_scaleAnimation = Tween<double>(begin: 0.8, end: 1.0).animate( | ||
CurvedAnimation(parent: _controller, curve: Curves.easeOutBack), | ||
); | ||
|
||
_controller.forward(); | ||
|
||
Timer(const Duration(seconds: 5), () { | ||
Navigator.pushReplacement( | ||
context, | ||
MaterialPageRoute(builder: (context) => const LandingPage()), | ||
); | ||
}); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_controller.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
backgroundColor: Colors.white, | ||
body: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
children: [ | ||
AnimatedBuilder( | ||
animation: _controller, | ||
builder: (context, child) { | ||
return Transform.scale( | ||
scale: _scaleAnimation.value, | ||
child: Opacity( | ||
opacity: _fadeInAnimation.value, | ||
child: Container( | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(100), | ||
), | ||
child: Center( | ||
child: Image.asset( | ||
"assets/images/splash.png", | ||
height: 200, | ||
width: 200, | ||
), | ||
), | ||
), | ||
), | ||
); | ||
}, | ||
), | ||
const SizedBox(height: 10), | ||
FadeTransition( | ||
opacity: _fadeInAnimation, | ||
child: const Text( | ||
"Curiosity Starts Here!", | ||
style: TextStyle( | ||
fontFamily: "Comic", | ||
fontSize: 20, | ||
color: Colors.black, | ||
), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
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