美文网首页
Flutter - Offstage、Visibility隐藏/

Flutter - Offstage、Visibility隐藏/

作者: 菲特峰 | 来源:发表于2020-12-08 18:05 被阅读0次
    image.png
    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,
      ),
    ),
    
    

    四种方式控制显隐

    import 'package:flutter/material.dart';
     
    class Test extends StatelessWidget {
      bool isShow=false;
      @override
      Widget build(BuildContext context) {
        return Container(
          child: Row(
            children: <Widget>[
              Visibility(child: null,visible:false,),
              Offstage(offstage:false,child:null),
              Opacity(opacity: 1,child:null),
              isShow?Text("显示"):SizedBox.shrink()
            ],
          ),
        );
      }
    }
    

    相关文章

      网友评论

          本文标题:Flutter - Offstage、Visibility隐藏/

          本文链接:https://www.haomeiwen.com/subject/szkqgktx.html