flutter 动画
Posted cap-rq
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了flutter 动画相关的知识,希望对你有一定的参考价值。
1. App闪屏动画(应用进入界面广告)案例:
import ‘package:flutter/material.dart‘; import ‘home_page.dart‘; // MyHomePage() class SplashScreen extends StatefulWidget { @override _SplashScreenState createState() => _SplashScreenState(); } // 混入 class _SplashScreenState extends State<SplashScreen> with SingleTickerProviderStateMixin { // 动画控制器 AnimationController _container; Animation _animation; @override void initState() { super.initState(); _container = AnimationController( vsync: this, duration: Duration(milliseconds: 3000)); _animation = Tween(begin: 0.0, end: 1.0).animate(_container); _animation.addStatusListener((status) { if (status == AnimationStatus.completed) { Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute(builder: (cintext) => MyHomePage()), // 显示完后跳转到首页 (route) => route == null, ); } }); _container.forward(); // 播放动画 } @override void dispose() { _container.dispose(); // 销毁控制器 super.dispose(); } @override Widget build(BuildContext context) { return FadeTransition( opacity: _animation, child: Image.network( ‘http://hbimg.b0.upaiyun.com/615efb61cbc8ec8aad8febdf5a74541fb79c54862658a-mPdqeZ_fw658‘, scale: 2.0, fit: BoxFit.cover, ), ); } }
以上是关于flutter 动画的主要内容,如果未能解决你的问题,请参考以下文章
错误记录Flutter 混合开发获取 BinaryMessenger 报错 ( FlutterActivityAndFragmentDelegate.getFlutterEngine() )(代码片段
在 webview_flutter 中启用捏合和缩放,在哪里添加代码片段 [this.webView.getSettings().setBuiltInZoomControls(true);]