title: flutter - How do position the value from the List to up?
body: <p>I have a <code>List&lt;Address&gt;</code> where in the <code>Address</code> class there are several keys, between:</p>
  
  <p><code>id</code>, <code>address</code>, <code>city</code> and <code>isPrimary</code>.</p>
  
  <p>I want to work with <code>isPrimary</code>, suppose that when I set <code>isPrimary</code> address from the list to <code>true</code> then that Address value positions to up (primary). how to do it?</p>
  
  <p>The following is the <code>List&lt;Address&gt;</code> that I mean:</p>
  
  <pre><code>[
    { 'id': 1,
      'address': '40 Talbot Ambler, PA 19002',
      'city': 'New York',
      'isPrimary': false
    },
  
    { 'id': 2,
      'address': '618 Oak Valley West Deptford, NJ 08096',
      'city': 'Sydney',
      'isPrimary': true
    },
  
    { 'id': 3,
      'address': '8207 Gulf Ringgold, GA 30736',
      'city': 'London',
      'isPrimary': false
    },
  
    { 'id': 4,
      'address': '873 Ridgewood St.Romeoville, IL 60446',
      'city': 'Manchester',
      'isPrimary': false
    },
  ]
  </code></pre>
  
  <p>I want Address that is <code>isPrimary = true</code> to be at the top of the List, followed by a list below with <code>isPrimary = false</code></p>
  
  <p>So that looks like this:</p>
  
  <pre><code>[
    { 'id': 2,
      'address': '618 Oak Valley West Deptford, NJ 08096',
      'city': 'Sydney',
      'isPrimary': true
    },
  
    { 'id': 1,
      'address': '40 Talbot Ambler, PA 19002',
      'city': 'New York',
      'isPrimary': false
    },
  
    { 'id': 3,
      'address': '8207 Gulf Ringgold, GA 30736',
      'city': 'London',
      'isPrimary': false
    },
  
    { 'id': 4,
      'address': '873 Ridgewood St.Romeoville, IL 60446',
      'city': 'Manchester',
      'isPrimary': false
    },
  ]
  </code></pre>
  
  <p>See my code below:</p>
  
  <pre><code>class UserAddressItemList extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return ScopedModelDescendant&lt;MainModel&gt;(
        builder: (context, child, model) {
          return model.isLoadingUser
              ? LoadingProgress
              : model.addressList == null
                  ? NoProductFound()
                  : ListView.builder(
                      physics: ClampingScrollPhysics(),
                      scrollDirection: Axis.horizontal,
                      itemCount:
                          model.addressList == null ? 0 : model.getAddressCount(),
                      itemBuilder: (context, i) {
                        var address = model.addressList[i];
                        return _buildAddressItemList(address, context);
                      },
                    );
        },
      );
    }
  
    Widget _buildAddressItemList(Address address, BuildContext context) {
      return Container(
          padding: EdgeInsets.symmetric(horizontal: 3),
          height: 150,
          width: 280,
          child: Card(
              // color: Colors.blueGrey,
              elevation: 2.0,
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.all(Radius.circular(10))),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: &lt;Widget&gt;[
                  SizedBox(height: 15),
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: &lt;Widget&gt;[
                      Container(
                        margin: EdgeInsets.only(left: 20),
                        // color: Colors.greenAccent,
                        width: 120,
                        child: Text(
                          '${address.address}\n'
                              '${address.city}',
                          style: Theme.of(context).textTheme.title.copyWith(
                              fontSize: 16,
                              fontWeight: FontWeight.w400,
                              height: 1.1),
                        ),
                      ),
                      Container(
                          padding: EdgeInsets.only(right: 15),
                          child: Icon(
                            FontAwesomeIcons.minus,
                            size: 16,
                            color: Colors.red,
                          ))
                    ],
                  ),
                  SizedBox(height: 5),
                  Container(
                      height: 20,
                      //  color: Colors.green,
                      margin: EdgeInsets.symmetric(horizontal: 10),
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.end,
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: &lt;Widget&gt;[
                          Container(
                              padding: EdgeInsets.only(bottom: 2),
                              child: Text(
                                "Delivery Address",
                                style: Theme.of(context)
                                    .textTheme
                                    .caption
                                    .copyWith(
                                        fontSize: 12, color: Colors.grey[400]),
                              )),
                          SizedBox(width: 10),
                          Container(
                            child: Icon(FontAwesomeIcons.solidCheckCircle,
                                size: 20,
                                color: address.isPrimary
                                    ? Colors.blue[600]
                                    : Colors.grey),
                          )
                        ],
                      )),
                  SizedBox(height: 5),
                ],
              )));
    }
  }
  </code></pre>