Show/hide widgets in Flutter programmatically

前端 未结 13 1218
轮回少年
轮回少年 2020-11-28 04:13

In Android, every single View subclass has a setVisibility() method that allows you modify the visibility of a View object

The

13条回答
  •  有刺的猬
    2020-11-28 04:31

    You can encapsulate any widget in your code with a new widget called (Visibility), this is from the yellow lamp at the very left side of the widget that you want it to be in-visible

    example: say you want to make a row invisible:

    1. Click in the lamp and choose (Wrap with widget)
    2. Rename the widget to Visibility
    3. Add the visible property and set it to false
    4. The Child of the newly created widget (Visibility Widget) is the Widget that you want it to be invisible

                Visibility(
                    visible: false,
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        SizedBox(
                          width: 10,
                        ),
                        Text("Search",
                          style: TextStyle(fontSize: 20
                          ),),
                      ],
                    ),
                  ),
      

    I hope it will help someone in the future

提交回复
热议问题