flutter 隐藏且不保留位置组件Offstage

  Offstage(
    offstage: 布尔值,    当为true时,将隐藏组件且不保留空间位置
    child: 组件,
  )

代码示例:

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Container(
       child: ListView(
         children: <Widget>[
         
           Offstage(
             offstage: true,
             child: Text('ahh'),
           ),
           Text('bb')
         ],
       ),
    );
  }
}
发布了675 篇原创文章 · 获赞 4 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_43294560/article/details/105663695
今日推荐