下面这个示例, 点击将放大或缩小

  1. double sideLength = 50;
  2. Widget build(BuildContext context) {
  3. return Center(
  4. child: AnimatedContainer(
  5. height: sideLength,
  6. width: sideLength,
  7. duration: Duration(seconds: 2),
  8. curve: Curves.easeIn,
  9. child: Material(
  10. color: Colors.yellow,
  11. child: InkWell(
  12. child: Text(
  13. 'hello',
  14. style: TextStyle(
  15. fontSize: 16,
  16. color: const Color(0xFFCCCCCC),
  17. ),
  18. ),
  19. onTap: () {
  20. setState(() {
  21. sideLength == 50 ? sideLength = 100 : sideLength = 50;
  22. });
  23. },
  24. ),
  25. ),
  26. ),
  27. );
  28. }

效果:
004.gif

参考资料