Offstage是控制组件隐藏/可见的组件,如果感觉有些单调功能不全,我们可以使用Visibility,Visibility也是控制子组件隐藏/可见的组件。不同是的Visibility有隐藏状态是否留有空间、隐藏状态下是否可调用等功能。

Flutter Offstage、Visibility隐藏/可见

 

Offstage(
  offstage:false,
  child: Container(
    width: 200,
    height: 200,
    color: Colors.red,
  ),
),
Visibility(
  visible:_offstage,
  replacement:Text('data'),
  maintainState:true,
  child: Container(
    width: 200,
    height: 200,
    color: Colors.yellow,
  ),
),

 

相关文章:

  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
猜你喜欢
  • 2022-01-22
  • 2021-06-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2022-01-13
相关资源
相似解决方案