animation.dart 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/services.dart';
  3. class DemoPage extends StatefulWidget {
  4. const DemoPage({Key? key}) : super(key: key);
  5. @override
  6. State<DemoPage> createState() => _DemoPageState();
  7. }
  8. class _DemoPageState extends State<DemoPage> with SingleTickerProviderStateMixin{
  9. AnimationController? controller0;
  10. Animation<double>? widthAni;
  11. // late Animation alphaAnimation;
  12. // AnimationController controller1;
  13. double top = -30.0;
  14. double opacity1 = 0.0;
  15. @override
  16. Widget build(BuildContext context) {
  17. SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
  18. return Container(
  19. color: Colors.white,
  20. child: SizedBox(width: 100.0,height: 100.0,child: Container(color: Colors.orange,),),
  21. // child: Container(height: 100,width: 100,color: Colors.blue,),
  22. // child: Stack(
  23. // children: [
  24. // // AnimatedPositioned(
  25. // // child: AnimatedOpacity(opacity: opacity1,child: Container(height: 50,width: widthAni!.value,color: Colors.red,),duration: const Duration(milliseconds: 200),),
  26. // // duration: const Duration(milliseconds: 200),
  27. // // top: top,
  28. // // ),
  29. // Container(height: widthAni!.value,width: widthAni!.value,color: Colors.blue,)
  30. // ],
  31. // ),
  32. );
  33. }
  34. @override
  35. void initState() {
  36. super.initState();
  37. // controller0 = AnimationController(vsync: this,duration: const Duration(milliseconds: 2000));
  38. // controller0!.addStatusListener((status) { });
  39. // widthAni = Tween(begin: 50.0, end: 200.0).animate(CurvedAnimation(parent: controller0!, curve: const Interval(0.0,1.0)));
  40. // controller0!.forward();
  41. // alphaAnimation =
  42. // Timer(const Duration(seconds: 1), (){
  43. // controller0!.forward();
  44. // setState(() {
  45. // top = 60;
  46. // opacity1 =1;
  47. // });
  48. // });
  49. }
  50. }