Reputation: 179
I have following array in firestore
I am using following code to read it;
List companies= [];
fireData() async {
var _dataC = await
FirebaseFirestore.instance.collection('comp').doc(uida).collection('comp').get();
var comList= await _dataC.docs.map((e) => e.get('skills')).toList();
setState(() {
companies=comList;
});
}
I am able to fetch records and put them in a listview builder. But these 3 names are not appearing with their index but everything is appearing in one text as [tcs, infy, wipro]
I need to get individual elements on the list. Length of the list is showing as 1 instead of 2.
I am using following code show these in ListView builder;
ListView.builder (
itemCount: companies.length,
itemBuilder: (BuildContext context, int index){
return Container(
width: size.width * 0.1,
child: Card(
child: ListTile(
leading: Text( companies[index][0], style:
TextStyle(color: Colors.black),),
),), ); })
With 0, i can manually access first element but i need a list view with all the elements displayed in separate cards. Please
Upvotes: 0
Views: 242
Reputation: 2033
I think by taking the list of skills, and writing it to a list, you created a List<List>
. So, either access it by calling skills[0][0], skills[0][1], etc or don't write it toList(), it's already a list, so you don't need to write it as such.
Upvotes: 0