title: flutter listView.Builder hide the divider on last list item
body: <p>How can one hide divider in the last item when creating list with ListView.Builder?</p>
  
  <p>It's fairly easy to add divider for each item, but what is the logic to dismiss divider on the last item in the list?</p>
  
  <p>There is no concrete stackoverflow question with a concrete example of implementing this task.</p>
  
  <pre><code>   Widget build(BuildContext context) {
  return 
      ListView.builder(
        shrinkWrap: true,
        physics: ScrollPhysics(),
        itemCount: OffersList.length,
        itemBuilder: (context, index) {
          Offer item = OffersList[index];
          return ListItem(context, item);
        },
      );
    }
  
  
  
  Widget ListItem(BuildContext context, Offer item) {
  if ( index == OffersList.length - 1) {
    dividerChecker = EmptyContainer();
  } else {
    dividerChecker = Divider();
  }
  return Column(
    children: &lt;Widget&gt;[
      OfferListItem(
        offerData: item,
        status: status,
        userType: userType,
      ),
      dividerChecker,
    ],
  );
  </code></pre>
  
  <p>}</p>
  
  <p>Solution as suggested:</p>
  
  <p>using ListView.separator instead of ListView.Builder:</p>
  
  <pre><code>        ListView.separated(
        separatorBuilder: (BuildContext context, int index) =&gt; new Divider(),
        shrinkWrap: true,
        physics: ScrollPhysics(),
        itemCount: OffersList.length,
        itemBuilder: (context, index) {
          Offer item = OffersList[index];
          return offerListItem(context, item);
        },
      ),
  Widget offerListItem(BuildContext context, Offer item) {
  return Column(
    children: &lt;Widget&gt;[
      OfferListItem(
        offerData: item,
        status: status,
        userType: userType,
      ),
    ],
  );
  </code></pre>
  
  <p>}</p>