GitHub

    Table of contents

  1. 示例
  2. 相关链接

AnimatedPadding

Edit this page

Animated version of Padding which automatically transitions the indentation over a given duration whenever the given inset changes.

示例

EdgeInsetsGeometry _padding = EdgeInsets.zero;
void _changePadding() {
  setState(() {
    if (_padding.left == 100) {
      _padding = EdgeInsets.only(top: 100, bottom: 100);
    } else {
      _padding = EdgeInsets.only(left: 100, right: 100);
    }
  });
}


Widget build(BuildContext context) {
  return Column(
    mainAxisSize: MainAxisSize.min,
    children: <Widget>[
      Container(
        height: 300.0,
        width: 300.0,
        child: AnimatedPadding(
          padding: _padding,
          curve: Curves.ease,
          duration: Duration(seconds: 1),
          child: Container(
            color: Colors.blue,
          ),
        ),
      ),
      FlatButton(
        onPressed: () {
          _changePadding();
        },
        child: Text(
          "Click Me!",
        ),
      )
    ],
  );
}

相关链接