zoukankan      html  css  js  c++  java
  • Flutter 容器(3)

    AnimatedPadding : 会产生动画效果的padding,在给定时间内缩放到指定padding

    import 'package:flutter/material.dart';
    
    class AuthList extends StatefulWidget {
      @override
      _AuthListState createState() => _AuthListState();
    }
    
    class _AuthListState extends State<AuthList> {
      // 方法和变量需要定义override之前
      double paddingVal = 20;
      _changePadding() {
        setState(() {
          paddingVal = paddingVal == 20.0 ? 100.0 : 20.0;
        });
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('代码测试'),
            centerTitle: true,
          ),
          body: Column(
            children: <Widget>[
              AnimatedPadding(
                padding: EdgeInsets.all(paddingVal),
                duration: Duration(microseconds: 3000),
                curve: Curves.easeInOut, // 弧线
                child: Container(
                  color: paddingVal == 20.0 ? Colors.redAccent: Colors.blue,
                  height: 200.0,
                ),
              ),
              RaisedButton(
                color: Colors.blue,
                child: Text(
                  'Toggle padding',
                  style: TextStyle(color: Colors.white),
                ),
                onPressed: _changePadding,
              )
            ],
          ),
        );
      }
    }
    
    Keep learning
  • 相关阅读:
    python基础4
    python的基础数据类型和编码
    python的if语句和while循环
    java特殊运算符
    深入理解java集合
    python常用模块
    python函数的参数问题
    集合关系之间的运算
    集合
    可变类型与不可变类型
  • 原文地址:https://www.cnblogs.com/leslie1943/p/13364747.html
Copyright © 2011-2022 走看看