GitHub

    Table of contents

  1. 示例
  2. 相关链接

AnimatedAlign

Edit this page

Animated version of Align which automatically transitions the child's position over a given duration whenever the given alignment changes.

示例

AlignmentGeometry _alignment = Alignment.topRight;

void _changeAlignment() {
  setState(() {
    _alignment = _alignment == Alignment.topRight ? Alignment.bottomLeft : Alignment.topRight;
  });
}


Widget build(BuildContext context) {
  return Column(
    mainAxisSize: MainAxisSize.min,
    children: <Widget>[
      Container(
        height: 120.0,
        width: 120.0,
        color: Colors.blue[50],
        child: AnimatedAlign(
          alignment: _alignment,
          curve: Curves.ease,
          duration: Duration(seconds: 3),
          child: FlutterLogo(
            size: 60,
          ),
        ),
      ),
      FlatButton(
        onPressed: () {
          _changeAlignment();
        },
        child: Text(
          "Click Me!",
        ),
      )
    ],
  );
}

相关链接