Created
March 16, 2022 16:02
-
-
Save BarryDaBee/06c022b080336997498516e56976c585 to your computer and use it in GitHub Desktop.
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
import 'dart:math' as math; | |
import 'package:flutter/material.dart'; | |
void main(){ | |
runApp(SplashScreen()); | |
} | |
class SplashScreen extends StatefulWidget{ | |
@override | |
State<SplashScreen> createState() => _SplashScreenState(); | |
} | |
class _SplashScreenState extends State<SplashScreen> with SingleTickerProviderStateMixin{ | |
late final AnimationController _animationController; | |
late final Animation<Color?> _colorTween; | |
late final Animation<Color?> _colorTween2; | |
@override | |
void initState(){ | |
_animationController = AnimationController(vsync: this, duration: const Duration(seconds: 2)); | |
_animationController..addListener((){ | |
setState((){}); | |
})..forward(); | |
_colorTween = ColorTween(begin: Colors.white, end: Colors.blue).animate(_animationController); | |
_colorTween2 = ColorTween(begin: Colors.white, end: Colors.green).animate(_animationController); | |
super.initState(); | |
} | |
@override | |
Widget build(BuildContext context){ | |
return MaterialApp( | |
home: Builder( | |
builder: (context) { | |
var longerSide = math.max(MediaQuery.of(context).size.height,MediaQuery.of(context).size.width); | |
var scaleFactor = 1.2; | |
double baseSize = 200.0; | |
return Scaffold( | |
backgroundColor: Colors.green, | |
body: Container( | |
height: double.maxFinite, | |
width: double.maxFinite, | |
color: _colorTween.value, | |
alignment: Alignment.center, | |
child: Stack( | |
alignment: Alignment.center, | |
children: [ | |
Transform.scale( | |
scale: ((longerSide * _animationController.value)/longerSide) * 5, | |
child: Container( | |
height: baseSize, | |
width: baseSize, | |
alignment: Alignment.center, | |
decoration: BoxDecoration( | |
color: _colorTween2.value, | |
shape: BoxShape.circle, | |
), | |
), | |
), | |
const Text('Moni Track and Potatoes', | |
style: TextStyle( | |
color: Colors.white, | |
), | |
) | |
], | |
) | |
), | |
); | |
} | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment