直接报错,没法这样写了
来源:7-7 动画Animation开发指南-AnimatedWidget与AnimatedBuilder-2【跟着做】
filway
2022-04-11
写回答
2回答
-
qq_麻烦_uwxM46
2022-09-18
我现在使用的是 flutter 3.3,要实现老师这效果具体参考:https://api.flutter.dev/flutter/widgets/AnimatedWidget-class.html
我的实现代码
import 'package:flutter/material.dart'; void main() { runApp(const LoggoApp()); } class LoggoApp extends StatefulWidget { const LoggoApp({Key? key}) : super(key: key); @override State<LoggoApp> createState() => _LoggoAppState(); } class AnimatedLogo extends AnimatedWidget { const AnimatedLogo({super.key, required AnimationController controller}) : super(listenable: controller); Animation<double> get _progress => listenable as Animation<double>; @override Widget build(BuildContext context) { return Center( child: Container( margin: EdgeInsets.symmetric(vertical: 10), height: _progress.value * 300, width: _progress.value * 300, child: FlutterLogo(), ), ); } } class _LoggoAppState extends State<LoggoApp> with SingleTickerProviderStateMixin { late Animation<double> animation; late AnimationController controller; @override void initState() { super.initState(); controller = AnimationController(vsync: this, duration: const Duration(seconds: 2)); controller.forward(); } @override void dispose() { controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return AnimatedLogo(controller: controller); } }
00 -
CrazyCodeBoy
2022-04-12
参考下这块课程源码做下空安全适配:https://git.imooc.com/coding-321/flutter_trip/src/master/doc/%E5%8A%A8%E7%94%BBAnimation%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97.md
00
相似问题