最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Flutter?Animation實現(xiàn)縮放和滑動動畫效果

 更新時間:2022年03月23日 08:02:27   作者:GalenWu  
這篇文章主要為大家詳細介紹了Flutter?Animation實現(xiàn)縮放和滑動動畫效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Flutter Animation實現(xiàn)縮放和滑動動畫的具體代碼,供大家參考,具體內(nèi)容如下

Animation對象是Flutter動畫庫中的一個核心類,它生成指導(dǎo)動畫的值。
Animation對象知道動畫的當(dāng)前狀態(tài)(例如,它是開始、停止還是向前或向后移動),但它不知道屏幕上顯示的內(nèi)容。
AnimationController管理Animation。
CurvedAnimation 將過程抽象為一個非線性曲線.
Tween在正在執(zhí)行動畫的對象所使用的數(shù)據(jù)范圍之間生成值。例如,Tween可能會生成從紅到藍之間的色值,或者從0到255。
使用Listeners和StatusListeners監(jiān)聽動畫狀態(tài)改變。

import 'package:flutter/animation.dart';
import 'package:flutter/material.dart';

void main() {
? runApp(new LogoApp());
}
class LogoApp extends StatefulWidget {
? _LogoAppState createState() => new _LogoAppState();
}

class _LogoAppState extends State<LogoApp> with SingleTickerProviderStateMixin {
? AnimationController controller;
? Animation<double> animation;

? initState() {
? ? super.initState();
? ? controller = new AnimationController(
? ? ? ? duration: const Duration(milliseconds: 10000), vsync: this);
? ? animation = new Tween(begin: 0.0, end: 300.0).animate(controller);
? ? controller.forward();
? }
??
? Widget build(BuildContext context) {
? ? return new AnimatedLogo(animation: animation);
? }

? dispose() {
? ? controller.dispose();
? ? super.dispose();
? }
}

class AnimatedLogo extends AnimatedWidget {
? AnimatedLogo({Key key, Animation<double> animation})
? ? ? : super(key: key, listenable: animation);

? Widget build(BuildContext context) {
? ? final Animation<double> animation = listenable;
? ? return new Center(
? ? ? child: new Container(
? ? ? ? margin: new EdgeInsets.symmetric(vertical: 10.0),
? ? ? ? height: animation.value,
? ? ? ? width: animation.value,
? ? ? ? child: new FlutterLogo(),
? ? ? ),
? ? );
? }
}

縮放功能

class ScaleAnimatedContent extends StatefulWidget {
? final Widget child;
? final bool show;

? const ScaleAnimatedContent({Key key, this.child, this.show = false})
? ? ? : super(key: key);

? @override
? ScaleAnimatedContentState createState() => ScaleAnimatedContentState();
}

class ScaleAnimatedContentState extends State<ScaleAnimatedContent>
? ? with TickerProviderStateMixin {
? AnimationController animationController;
? Animation<double> animation;

? @override
? void initState() {
? ? animationController = new AnimationController(
? ? ? vsync: this,
? ? ? duration: new Duration(milliseconds: 600),
? ? );

? ? // animationSlideUp = new Tween(begin: 0.0,end: 1.0).animate(animationController);
? ? animation = Tween(begin: 0.0, end: 1.0).animate(animationController);

? ? if (widget.show) {
? ? ? animationController.forward();
? ? }

? ? super.initState();
? }

? @override
? void didUpdateWidget(ScaleAnimatedContent oldWidget) {
? ? if (widget != oldWidget) {
? ? ? if (widget.show && !oldWidget.show) {
? ? ? ? animationController.forward(from: 0.0);
? ? ? } else if (!widget.show) {
? ? ? ? animationController.reverse();
? ? ? }
? ? }
? ? super.didUpdateWidget(oldWidget);
? }

? @override
? Widget build(BuildContext context) {
? ? return ScaleTransition(
? ? ? scale: animation,
? ? ? child: widget.child,
? ? );
? }

? @override
? void dispose() {
? ? animationController.dispose();
? ? super.dispose();
? }
}

滑動效果

class SlideAnimatedContent extends StatefulWidget {
? final Widget child;
? final bool show;

? const SlideAnimatedContent({Key key, this.child, this.show = false})
? ? ? : super(key: key);

? @override
? SlideAnimatedContentState createState() => SlideAnimatedContentState();
}

class SlideAnimatedContentState extends State<SlideAnimatedContent>
? ? with TickerProviderStateMixin {
? AnimationController animationController;
? Animation<Offset> animationSlideUp;

? @override
? void initState() {
? ? animationController = new AnimationController(
? ? ? vsync: this,
? ? ? duration: new Duration(milliseconds: 600),
? ? );

? ? animationSlideUp = new Tween(
? ? ? begin: Offset(0.0, 5.0),
? ? ? end: Offset(0.0, 0.0),
? ? ).animate(CurvedAnimation(parent: animationController, curve: Curves.ease));

? ? if (widget.show) {
? ? ? animationController.forward();
? ? }

? ? super.initState();
? }

? @override
? void didUpdateWidget(SlideAnimatedContent oldWidget) {
? ? if (widget != oldWidget) {
? ? ? if (widget.show && !oldWidget.show) {
? ? ? ? animationController.forward(from: 0.0);
? ? ? } else if (!widget.show) {
? ? ? ? animationController.reverse();
? ? ? }
? ? }
? ? super.didUpdateWidget(oldWidget);
? }

? @override
? Widget build(BuildContext context) {
? ? return SlideTransition(
? ? ? position: animationSlideUp,
? ? ? child: FadeTransition(
? ? ? ? opacity: animationController,
? ? ? ? child: widget.child,
? ? ? ),
? ? );
? }

? @override
? void dispose() {
? ? animationController.dispose();
? ? super.dispose();
? }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • android webview 簡單瀏覽器實現(xiàn)代碼

    android webview 簡單瀏覽器實現(xiàn)代碼

    android webview 簡單瀏覽器實現(xiàn)代碼,需要的朋友可以參考一下
    2013-05-05
  • Android編程之軟件的安裝和卸載方法

    Android編程之軟件的安裝和卸載方法

    這篇文章主要介紹了Android編程之軟件的安裝和卸載方法,涉及Android編程實現(xiàn)軟件的安裝、權(quán)限修改及卸載的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-12-12
  • 手寫android布局示例

    手寫android布局示例

    這篇文章主要介紹了手寫android布局示例,需要的朋友可以參考下
    2014-02-02
  • Android實現(xiàn)手勢滑動(左滑和右滑)

    Android實現(xiàn)手勢滑動(左滑和右滑)

    這篇文章主要為大家詳細介紹了Android實現(xiàn)手勢滑動,左滑和右滑效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-07-07
  • Android中控件GridView實現(xiàn)設(shè)置行列分割線的方法示例

    Android中控件GridView實現(xiàn)設(shè)置行列分割線的方法示例

    這篇文章主要介紹了利用Android中控件GridView實現(xiàn)設(shè)置行列分割線的方法,文中給出了詳細的介紹與示例代碼,相信對大家具有一定的參考價值,有需要的朋友們下面來一起看看吧。
    2017-01-01
  • Android搜索框SearchView屬性和用法詳解

    Android搜索框SearchView屬性和用法詳解

    這篇文章主要為大家詳細介紹了Android搜索框SearchView屬性和用法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • Android UI控件之Spinner下拉列表效果

    Android UI控件之Spinner下拉列表效果

    這篇文章主要為大家詳細介紹了Android UI控件之Spinner下拉列表效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-12-12
  • Android LinearLayout實現(xiàn)自動換行

    Android LinearLayout實現(xiàn)自動換行

    這篇文章主要為大家詳細介紹了Android LinearLayout實現(xiàn)自動換行,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-08-08
  • Android工程師面試題大全

    Android工程師面試題大全

    這篇文章主要為大家分享了Android工程師面試題,內(nèi)容很豐富,結(jié)合網(wǎng)上各位的大神秒下的面試題做個總結(jié),感興趣的小伙伴們可以參考一下
    2016-02-02
  • Android實現(xiàn)截圖分享qq 微信功能

    Android實現(xiàn)截圖分享qq 微信功能

    在日常生活中,經(jīng)常用到qq,微信截圖分享功能,今天小編通過本文給大家介紹Android實現(xiàn)截圖分享qq 微信功能,具體實現(xiàn)代碼大家參考下本文
    2017-12-12

最新評論

永康市| 鸡西市| 黑龙江省| 兴义市| 吴忠市| 临邑县| 阳原县| 安图县| 囊谦县| 精河县| 论坛| 阿巴嘎旗| 福建省| 巍山| 都江堰市| 双牌县| 揭西县| 鱼台县| 华蓥市| 扎囊县| 江津市| 东乡族自治县| 德庆县| 凤台县| 滦南县| 青神县| 东丽区| 沧州市| 烟台市| 桐柏县| 科技| 罗甸县| 新乡县| 岚皋县| 嘉善县| 民丰县| 若尔盖县| 林口县| 宁安市| 南郑县| 塔河县|