【问题标题】:Flutter - make a container invisibleFlutter - 使容器不可见
【发布时间】:2021-11-30 07:39:33
【问题描述】:

我正在尝试获得一个带有“弹出”图标的栏

带图标的栏

我的问题是即使我使用以下命令,包含对象的容器也不是不可见的:'color: Colors.trasparent'

Widget _bottomNavigator(String uid) {
    return Container(
      height: 50,
      color: Colors.transparent,
      child: Offstage(
        offstage: !_isVisible,
        child: Stack(children: [
          Align(
              alignment: Alignment.bottomCenter,
              child: Container(
                height: 20,
                color: iconColor,
              )),
          Align(
            alignment: Alignment.bottomCenter,
            child: Container(
              height: 50,
              constraints: BoxConstraints.tightForFinite(),
              color: Colors.transparent,
              child: TextButton.icon(
                icon: Icon(
                  Icons.add_photo_alternate,
                  color: gradientBeginColor,
                  size: 40,
                ),
                label: Text(
                  '',
                ),
                onPressed: () async {...},
              ),
            ),
          ),
        ]),

有谁知道如何使容器不再可见?

谢谢

【问题讨论】:

    标签: flutter dart flutter-layout containers alignment


    【解决方案1】:

    使用Visibility 小部件来控制小部件的可见性。

    Visibility(
      visible: false, // not visible if set false
      child: Container(
        ...
      ),
    ),
    

    【讨论】:

    • 我尝试使用它,但结果所有栏都消失了,因为元素是它的子元素
    • 仅包装您想要控制其可见性的小部件。
    【解决方案2】:

    试试这个,使用Opacity,使用opacity: 0.0,然后使用opacity包装小部件

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-09
      • 1970-01-01
      • 2014-03-31
      • 1970-01-01
      • 2022-11-16
      • 1970-01-01
      • 2022-08-22
      • 1970-01-01
      相关资源
      最近更新 更多