AnimatedSize

AnimatedSize可以不需要传高度就有有动画,Offstage控制显隐,不会销毁组件

  1. AnimatedSize(
  2. // reverseDuration: Duration(milliseconds: 200),
  3. duration: Duration(milliseconds: 200),
  4. child: Offstage(
  5. child: InheritedProvider(
  6. data: item.isExpand == true,
  7. child: GetSeriverCardList(item, item.isExpand == true),
  8. ),
  9. offstage: !(item.isExpand == true), // 是要偏移
  10. ),
  11. )

AnimatedContainer

AnimatedContainer需要知道高度才会有有动画,Visibility控制显隐,但会销毁组件

  1. // AnimatedContainer(
  2. // // height: item.isExpand == true ? 100 : 0,
  3. // duration: Duration(milliseconds: 300),
  4. //
  5. // child: Offstage(
  6. // child: InheritedProvider(
  7. // data: item.isExpand == true,
  8. // child: GetSeriverCardList(item, item.isExpand == true),
  9. // ),
  10. // offstage: item.isExpand == true,
  11. // ),
  12. // child: Visibility(
  13. // child: GetSeriverCardList(item, item.isExpand == true),
  14. // visible: item.isExpand == true,
  15. // replacement: Container(),
  16. // ),
  17. // child: item.isExpand == true ? GetSeriverCardList(item) : SizedBox(),
  18. // child: Opacity(
  19. // opacity: item.isExpand == true ? 1 : 0,
  20. // child: GetSeriverCardList(item),
  21. // ),
  22. // ),