Code:
import 'dart:async';
import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:animations/animations.dart';
import 'package:flutter/material.dart';
import 'package:page_transition/page_transition.dart';
class SplashScreen4 extends StatefulWidget {
@override
_SplashScreen4State createState() => _SplashScreen4State();
}
class _SplashScreen4State extends State<SplashScreen4> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Center(
child: OpenContainer(
closedBuilder: (_, openContainer) {
return Container(
height: 60,
width: 220,
child: Center(
child: Text(
'View Splash Animation',
textAlign: TextAlign.center,
),
),
);
},
openColor: Colors.indigo,
closedElevation: 20,
closedShape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
transitionDuration: Duration(milliseconds: 700),
openBuilder: (_, closeContainer) {
return SplashScreen4Sub();
},
),
),
),
);
}
}
class SplashScreen4Sub extends StatefulWidget {
@override
_SplashScreen4SubState createState() => _SplashScreen4SubState();
}
class _SplashScreen4SubState extends State<SplashScreen4Sub>
with TickerProviderStateMixin {
AnimationController scaleController;
Animation<double> scaleAnimation;
@override
void initState() {
super.initState();
scaleController = AnimationController(
vsync: this,
duration: Duration(milliseconds: 600),
)..addStatusListener(
(status) {
if (status == AnimationStatus.completed) {
Navigator.of(context).pushReplacement(
PageTransition(
type: PageTransitionType.bottomToTop,
child: ThirdPage(),
),
);
Timer(
Duration(milliseconds: 300),
() {
scaleController.reset();
},
);
}
},
);
scaleAnimation =
Tween<double>(begin: 0.0, end: 12).animate(scaleController);
Timer(Duration(seconds: 2), () {
setState(() {
scaleController.forward();
});
});
}
@override
void dispose() {
scaleController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.indigo,
body: Center(
child: DefaultTextStyle(
style: TextStyle(fontSize: 30.0),
child: AnimatedTextKit(
animatedTexts: [
TyperAnimatedText(
'APP NAME',
speed: Duration(milliseconds: 150),
),
],
isRepeatingAnimation: false,
repeatForever: false,
displayFullTextOnTap: false,
),
),
),
);
}
}
class ThirdPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Go Back'),
centerTitle: true,
brightness: Brightness.dark,
backgroundColor: Colors.indigo,
),
body: Center(
child: Text(
"HOME",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
),
),
),
);
}
}
0 Comments