请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

老师,我用你的源码跑的也没有动画效果

import ‘package:flutter/animation.dart’;
import ‘package:flutter/material.dart’;

// #docregion LogoWidget
class LogoWidget extends StatelessWidget {
// Leave out the height and width so it fills the animating parent
Widget build(BuildContext context) => Container(
margin: EdgeInsets.symmetric(vertical: 10),
child: FlutterLogo(),
);
}
// #enddocregion LogoWidget

// #docregion GrowTransition
class GrowTransition extends StatelessWidget {
GrowTransition({this.child, this.animation});

final Widget child;
final Animation animation;

Widget build(BuildContext context) => Center(
child: AnimatedBuilder(
animation: animation,
builder: (context, child) => Container(
height: animation.value,
width: animation.value,
child: child,
),
child: child),
);
}
// #enddocregion GrowTransition

class LogoApp extends StatefulWidget {
_LogoAppState createState() => _LogoAppState();
}

// #docregion print-state
class _LogoAppState extends State with SingleTickerProviderStateMixin {
Animation animation;
AnimationController controller;

@override
void initState() {
super.initState();
controller =
AnimationController(duration: const Duration(seconds: 2), vsync: this);
animation = Tween(begin: 0, end: 300).animate(controller);
controller.forward();
}
// #enddocregion print-state

@override
Widget build(BuildContext context) => GrowTransition(
child: LogoWidget(),
animation: animation,
);

@override
void dispose() {
controller.dispose();
super.dispose();
}
// #docregion print-state
}

正在回答 回答被采纳积分+3

问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信