zoukankan      html  css  js  c++  java
  • AnimatedContainerWidget(每日Flutter 小部件)

    AnimatedContainerWidget

    AnimatedContainer({
    Key key,
    this.alignment,
    this.padding,
    Color color,
    Decoration decoration,
    this.foregroundDecoration,
    double width,
    double height,
    BoxConstraints constraints,
    this.margin,
    this.transform,
    this.child,
    Curve curve = Curves.linear,
    @required Duration duration,
    })
    import 'package:flutter/material.dart';

    class AnimatedContainerWidget extends StatefulWidget {
    AnimatedContainerWidget({Key key}) : super(key: key);

    _AnimatedContainerWidgetState createState() =>
    _AnimatedContainerWidgetState();
    }

    class _AnimatedContainerWidgetState extends State<AnimatedContainerWidget> {
    double _opacity = 1.0;
    Matrix4 _transform = Matrix4.translationValues(0, 0, 0);

    void _onTapHandle() {
    setState(() {
    _opacity = _opacity == 1.0 ? 0.0 : 1.0;
    _transform = _opacity == 0.0
    ? Matrix4.translationValues(-300, 0, 0)
    : Matrix4.translationValues(0, 0, 0);
    });
    }

    @override
    Widget build(BuildContext context) {
    return Stack(
    children: <Widget>[
    Center(
    child: Column(children: <Widget>[
    AnimatedContainer(
    alignment: Alignment.center,
    padding: EdgeInsets.all(5),
    foregroundDecoration: BoxDecoration(
    color: Colors.transparent),
    200,
    height: 200,
    constraints: BoxConstraints(minHeight: 200),
    curve: Curves.easeInToLinear,
    duration: Duration(milliseconds: 500),
    transform: _transform,
    child: Container(
    alignment: Alignment.center,
    100,
    height: 50,
    color: Colors.blue,
    ))
    ]),
    ),
    Positioned(
    bottom: 1,
    right: 1,
    child: InkWell(
    child: Container(
    30,
    height: 30,
    margin: EdgeInsets.fromLTRB(0, 0, 10, 10),
    decoration: BoxDecoration(
    borderRadius: BorderRadius.circular(30),
    color: Colors.pink,
    ),
    child: Icon(
    Icons.play_arrow,
    color: Colors.white,
    ),
    ),
    onTap: _onTapHandle,
    ),
    )
    ],
    );
    }
    }

  • 相关阅读:
    设置N秒后执行某个方法或函数
    3D Touch的简单使用
    iOS app 上架的流程与注意点
    使用ueditor时候修改图片路径及其相关信息
    给某个view增加颜色渐变图层
    文字冒泡效果
    iOS获取设备型号、设备类型等信息
    “匿名内部类”的使用场合举例
    TreeSet之用外部比较器实现自定义有序(重要)
    TreeSet的运用之使用内部比较器实现自定义有序(重要)
  • 原文地址:https://www.cnblogs.com/wjw334/p/12560508.html
Copyright © 2011-2022 走看看