title: Flutter/Firebase-How to perform delete document functionality when document ID is not known?
body: <p>I am new to flutter and developing an application in which I am displaying data in the from of ListView. There is a delete IconButton in it. I want that the selected ListTile data should be deleted. It is displaying data in the form of List but not deleting.
  After I have added the deleteData() method. It is showing the following error:</p>
  
  <blockquote>
    <p>'package:flutter/src/rendering/silver_multi_box_adaptor.dart':Failed
    assertion: line 263 pos 16: 'child == null || indexOf(child) > index'
    : is not true.</p>
  </blockquote>
  
  <p>Any help is highly appreciated. Here is what I have done so far:</p>
  
  <pre><code>class OrderRequestModel extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        home: UserOrderRequestModel(),
        theme: new ThemeData(
          primarySwatch: Colors.red,
        ),
      );
    }
  }
  
  class UserOrderRequestModel extends StatefulWidget {
    @override
    _UserOrderRequestModelState createState() {
      return _UserOrderRequestModelState();
    }
  }
  
  class _UserOrderRequestModelState extends State&lt;UserOrderRequestModel&gt; {
    deleteData(docId) {
      Firestore.instance
          .collection('order_tbl')
          .document(docId)
          .delete()
          .catchError((e) {
        print(e);
      });
    }
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: _buildBody(context),
      );
    }
    Stream&lt;QuerySnapshot&gt; getData() async*{
      FirebaseUser firebaseUser = await FirebaseAuth.instance.currentUser();
      yield* Firestore.instance.collection('order_tbl').orderBy('timestamp', descending: true).snapshots();
    }
  
    Widget _buildBody(BuildContext context) {
      return StreamBuilder&lt;QuerySnapshot&gt;(
        stream: getData(),
        builder: (context, snapshot) {
          if (!snapshot.hasData) return LinearProgressIndicator();
          return _buildList(context, snapshot.data.documents);
        },
      );
    }
  
    Widget _buildList(BuildContext context, List&lt;DocumentSnapshot&gt; snapshot) {
      return ListView(
        padding: const EdgeInsets.only(top: 5.0),
        children: snapshot.map((data) =&gt; _buildListItem(context, data)).toList(),
      );
    }
  
    Widget _buildListItem(BuildContext context, DocumentSnapshot data) {
      final record = Record.fromSnapshot(data);
      String _string =getTimeDifferenceFromNow(record.timestamp.toDate());
      return Padding(
        key: ValueKey(record.animal),
        padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
        child: Container(
            decoration: BoxDecoration(
              border: Border.all(color: Colors.grey),
              borderRadius: BorderRadius.circular(5.0),
            ),
            child: new ListTile(
              title: new Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: &lt;Widget&gt;[
                  new Text(
                    "${record.quantity} kg ${record.animal} - ${record.mobile}",
                    style: new TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
                  ),
                  new Text(
                    _string,
                    style: new TextStyle(color: Colors.grey, fontSize: 12.0),
                  ),
                ],
              ),
              trailing: IconButton(
                icon: Icon(Icons.delete_forever),
                onPressed: () =&gt; deleteData(data.documentID),
              ),
  
              subtitle: new Container(
                padding: const EdgeInsets.only(top: 5.0),
                child: new Text(
                  record.address,
                  style: new TextStyle(color: Colors.red, fontSize: 12.0,),
                ),
              ),
            ),
        ),
      );
    }
  }
  </code></pre>