title: How to change the position after disabling visibility of the widget in flutter?
body: <p>I'm new to flutter. I'm displaying the cards based on the list of items. By using switch button I am trying to show only the Priority items. When switch is &quot;ON&quot; I need to display Only Priority items, while it's OFF I need to display the entire list of items.</p>
  <p>I have achieved this using Switch and Visibility widget, but the position of the cards didn't change.
  Here is What I have done so far,</p>
  <p>Code:</p>
  <p>For passing the list items,</p>
  <pre><code> @override
    Widget build(BuildContext context) {
      const curveHeight = 15.0;
  
      return new Scaffold(
          appBar: AppBar(
            centerTitle: true,
            title: Text(dashboardTitle),
            shape: const MyShapeBorder(curveHeight),
            leading: Switch(
              value: isSwitched,
              onChanged: (value) {
                setState(() {
                  isSwitched = value;
                  dashboardTitle =
                      (isSwitched) ? 'Priority Alerts' : 'All Alerts';
                  showPriority = (isSwitched) ? true : false;
                });
              },
              activeTrackColor: Colors.red[400],
              activeColor: Colors.red[600],
            ),
            actions: &lt;Widget&gt;[
              IconButton(
                icon: Icon(IconData(0xe848, fontFamily: 'MaterialIcons')),
                onPressed: () async {
                  await removeWorkManager();
                  await logout();
                },
              )
            ],
          ),
          body: Center(
              child: Container(
                  color: Colors.red[200],
                  child: CustomPaint(
                      painter: CurvePainter(),
                      child: OrientationBuilder(builder: (context, orientation) {
                        return FutureBuilder&lt;List&lt;Choice&gt;&gt;(
                          future: choices,
                          builder: (context, snapshot) {
                            if (snapshot.hasData) {
                              return GridView.builder(
                                  itemCount: snapshot.data.length,
                                  gridDelegate:
                                      SliverGridDelegateWithFixedCrossAxisCount(
                                    crossAxisCount:
                                        orientation == Orientation.portrait
                                            ? 2
                                            : 4,
                                    crossAxisSpacing: 2.0,
                                    mainAxisSpacing: 8.0,
                                  ),
                                  itemBuilder: (BuildContext context, index) {
                                    //  print(snapshot.data[index]);
                                    return Center(
                                      child: SelectCard(
                                          choice: snapshot.data[index]),
                                    );
                                  });
                            } else if (snapshot.hasError) {
                              print(snapshot);
                              return Text(&quot;Error&quot;);
                            }
                            return Text(&quot;Loading...&quot;);
                          },
                        );
                      })))));
  </code></pre>
  <p>Here is Card Creation class,</p>
  <pre><code>class _SelectCard extends State&lt;SelectCard&gt; {
    bool loading = false;
    double progress = 0;
  
    final Choice choice;
  
    _SelectCard(this.choice);
  
    @override
    Widget build(BuildContext context) {
      final TextStyle titleStyle = TextStyle(
          fontWeight: FontWeight.bold,
          fontSize: 15.0,
          color: new Color(int.parse(choice.colors)));
      final TextStyle alertStyle = TextStyle(
          fontWeight: FontWeight.bold, fontSize: 14.0, color: Colors.black);
      final TextStyle messageStyle = TextStyle(
          fontWeight: FontWeight.bold, fontSize: 12.0, color: Colors.green[800]);
  
      bool showOperator = false;
  
      if (showPriority) {
        if (choice.priority == '1') {
          showOperator = false;
        } else {
          showOperator = true;
        }
      }
      return Visibility(
          visible: showOperator,
          child: Container(
              child: Card(
            elevation: 20,
            color: Colors.white,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.all(Radius.circular(10)),
              side: BorderSide(color: Colors.white),
            ),
            child: Container(
              child: InkWell(
                onTap: () {},
                child: Center(
                  child: Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: &lt;Widget&gt;[
                        Padding(
                          padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
                        ),
                        Container(
                            child: Column(
                          children: &lt;Widget&gt;[
                            Text(
                              choice.title,
                              style: titleStyle,
                              textAlign: TextAlign.center,
                            ),
                            SizedBox(height: 5),
                            Text(
                              choice.alertName,
                              style: alertStyle,
                              textAlign: TextAlign.start,
                            ),
                            SizedBox(height: 5),
                            Text(
                              choice.alertMessage,
                              style: messageStyle,
                              textAlign: TextAlign.start,
                            ),
                          ],
                        )),
                      ]),
                ),
              ),
            ),
          )));
    }
  }
  
  
  I have also tried with Offstage widget, but the result was same. Sorry, I can't able post my screen shot directly because of my low reputation points.
  </code></pre>
  <p><a href="https://i.stack.imgur.com/UvV8f.png" rel="nofollow noreferrer">My Full List items screen.</a>&amp;
  <a href="https://i.stack.imgur.com/mRa8m.png" rel="nofollow noreferrer">My Priority list item screen.</a>.</p>
  <p>As you can see in the above pictures ,when I am displaying the priority items, it displays the card in the second position while it should be first.</p>
  <p>Any help would be great!. Thanks in advance.</p>