0
I have a list that I will use to form a Drawer, passing it title, link and icon.
List<List<String>> DrawerList = [
["Perfil", "/perfil","Icons.vpn_key"],
["Turmas", "/turmas","Icons.vpn_key"],
["Alunos", "/alunos","Icons.vpn_key"],
["Conteudo", "/conteudos","Icons.vpn_key"],
["Relatórios", "/relatorios","Icons.vpn_key"],
["Exercícios", "/exericios","Icons.vpn_key"],
["Sair", "/sair","Icons.vpn_key"]
];
I’m riding the Drawer using Listview:
drawer: Drawer(
child: Flexible(
child: ListView.builder(
itemCount: DrawerList.length,
itemBuilder: (context, index) {
return DrawerContent(
tileTitle: context.toString(DrawerList),
tileIcon: DrawerList[index],
);
},
),
),
),
And I have a class called Drawercontent, where I actually mount Drawer.
return Padding(
padding: const EdgeInsets.only(bottom: 8, top: 8),
child: Container(
width: 90,
height: 90,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset: Offset(0, 3),
),
],
),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
child: ListTile(
title: Text(widget.tileTitle), trailing: Icon(widget.tileIcon)),
),
),
);
Taking all this into consideration, my question is, how do I go through the list so that I can call the fields inside my Listview?
You want a Listview where each element relates to an element in your list
DrawerList? From what I’ve seen, Tileicon is the last element of the sublist. So you can use two brackets followed by the form:tileTitle: DrawerList[index][0],andtileIcon: DrawerList[index][2]. I don’t know if that’s what you want or what the difficulty was. If you can edit the question to add these points, it would help anyone who answers. :)– Naslausky