Flutter: use Data outside of function

Job ID: 35002462

Budget: €8 – €30 EUR

Let say i have:


List<Employee> lst = [];


readData() async {

FirebaseFirestore.instance

.collection('Employee')

.get()

.then((QuerySnapshot querySnapshot) {

querySnapshot.docs.forEach((doc) {

Employee e = Employee(

uid: doc.id,

contactno: doc.data().toString().split(',')[0].split(':')[1],

employeename: doc.data().toString().split(',')[1].split(':')[1],

position: doc

.data()

.toString()

.split(',')[2]

.split(':')[1]

.split('}')[0]);

lst.add(e);

print('---------------------------------');

print('uid=${e.uid}');

print('Employee name=${e.employeename}');

print('Contact no=${e.contactno}');

print('position=${e.position}');

});
});
}

...how can i use the data i just printed outside the readData-function? thx
Related categories: Dart Flutter