zoukankan      html  css  js  c++  java
  • flutter 按钮弹簧动画AnimationController

    效果图:

    
    

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

    class SLHomePage extends StatefulWidget {
    @override
    State<StatefulWidget> createState() {
    return _SLHomePageState();
    }
    }
    class _SLHomePageState extends State<SLHomePage> with SingleTickerProviderStateMixin{
    late AnimationController _controller;
    late Animation<double> _animation;
    late Tween<double> _tween;
    @override
    void initState() {
    super.initState();
    _controller = AnimationController(vsync: this,duration: const Duration(milliseconds: 400));
    _animation = CurvedAnimation(parent: _controller, curve: Curves.elasticOut,reverseCurve:Curves.elasticInOut);
    _tween = Tween(begin: 0.7,end: 1);
    _controller.forward();
    }
    @override
    void dispose() {
    _controller.dispose();
    super.dispose();
    }
    @override
    Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
    height: MediaQuery.of(context).size.height,
    child: Center(
    child: Container(
    200,
    height: 90,
    child: ScaleTransition(scale: _tween.animate(_animation),child: TextButton(
    child: Text('按钮'),
    onPressed: (){
    _controller.repeat();
    setState(() {
    _controller.forward();
    });
    }
    )
    )
    ),
    ),
    );
    }
    }
     
  • 相关阅读:
    增加/删除新用户并添加root权限
    LINUX学习之路-1
    了解参考基因组及注释信息
    RNA-seq操作实战
    如何利用数据库下载参考基因组
    RNA-Seq比对软件HISAT2的用法
    小白-批量下载SRR数据
    sratoolkit 的使用
    批量查看QC结果的工具----multiqc
    fastQC 质控结果解读
  • 原文地址:https://www.cnblogs.com/lulushen/p/15433717.html
Copyright © 2011-2022 走看看