Use local variable outside the function with dart

Viewed 74

i want to use "docid" outside the function how to do it ?

  getC() async {
    Usersref.where("email", isEqualTo: widget.list['email'])
        .get()
        .then((QuerySnapshot snapshot) {
      snapshot.docs.forEach((document) {
        print(document.id);
        final docid = document.id;
        
      });
      
    });
  }
1 Answers
Future<List<String>>getC() async {
List<String> idList=[];
await Usersref.where("email", isEqualTo: widget.list['email'])
    .get()
    .then((QuerySnapshot snapshot) {
  snapshot.docs.forEach((document) {
    print(document.id);
    idList.add( document.id);
    
  });
  
});
return idList;
}

Related