I want to access fname which is an array in firestore and if it is present print found or else not found but i am not able to access an array.
where as if fname is create as string int firestore than i am able to print "Found"
return StreamBuilder(
stream: Firestore.instance.collection('users').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return Text('Loading Data');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) {
return Card(
child: ListTile(
leading: snapshot.data.documents[index].data['user'] == ["John"]
? Text("Found")
: Text('No position found'),
Solution 1: hasan karaman-goodsoft
await _refdata.child("users").once().then((DataSnapshot snap2) {
bool result;
result= snap2.value.where((element)=> elemet.devices.fname=="jhon);
});
leading:
result ==true
? Text("Found")
: Text('No position found'),
------or-------
leading:
Text(snapshot.data.documents[index].data[""devices].data['fname'])=="John"
? Text("Found")
: Text('No position found'),