-2
Good morning!
Could someone assist me in a doubt?
What am I doing:
I did a search for the user to search for an Infringement or Attachments etc in the app, and soon after the action on the keyboard I redirect it to another page (Filtroinicioview) passing the data as parameter.
onFieldSubmitted: (string) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => FiltroinicioView(filterNomeInfracao, filterNomeAnexo),
),
);
},
After redirecting the user to the View page of the infraction and searched attachments, I show the List of Infractions, and attachments,
body: Column(
children: <Widget>[
Expanded(
child: ListView.builder(
padding: EdgeInsets.all(10.0),
itemCount: filterNomeInfracao.length +
filterNomeAnexo.length
itemBuilder: (BuildContext context, int index) {
print(filterNomeInfracao);
print(filterNomeAnexo);
},
Return of Print:
[Infracao{id: null, descricao: , codigo: INFRAÇÕES, art_ctb: null, pontuacao_id: null, observacao: null, foto: null, procedimento_id: null, categoria_id: null, created: null, modified: null, deleted: null}, Infracao{id: 34, descricao: CONFIAR/ ENTREGAR veículo a pessoa em estado FÍSICO/ PSÍQUICO SEM CONDIÇÕES de dirigir com segurança, codigo: 517-7_0, art_ctb: 166, pontuacao_id: 5, observacao: Conforme Resolução CONTRAN 561/2015.
[Anexo{id: 40, nome: GESTOS DE AGENTES, conteudo: movimentos convencionais de braço, adotados exclusivamente pelos agentes de autoridades de trânsito nas vias, para orientar, indicar o direi
My doubt is how I can know now inside the itemBuilder: (Buildcontext context, int index) { which list is from Infringements and which list is attachments because I need to do an IF now or be
if(for a lista ANEXOS){
faz alguma coisa
}
if( for a lista INFRACOES){
faz alguma coisa
}
AS QUOTED IN THE COMMENTARY THE FORM MADE:
body: Column(
children: <Widget>[
Expanded(
child: ListView.builder(
padding: EdgeInsets.all(10.0),
itemCount: filterNomeInfracao.length,
itemBuilder: (BuildContext context, int index) {
if (index < filterNomeInfracao.length) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: EdgeInsets.fromLTRB(0.0, 25.0, 20.0, 1.0),
child: ListTile(
title: Text(
'INFRAÇÕES.',
style: TextStyle(
fontSize: 28.0,
),
),
),
),
],
);
}
return ListaInfracao(filterNomeInfracao[index]);
},
),
),
Expanded(
child: ListView.builder(
padding: EdgeInsets.all(10.0),
itemCount: filterNomeInfracao.length,
itemBuilder: (BuildContext context, int index) {
if (index < filterNomeAnexo.length) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: EdgeInsets.fromLTRB(0.0, 25.0, 20.0, 1.0),
child: ListTile(
title: Text(
'ANEXOS.',
style: TextStyle(
fontSize: 28.0,
),
),
),
),
],
);
}
return ListaAnexos(filterNomeAnexo[index]);
},
),
),
],
));
HOW YOU ARE BRINGING THE DATA (YOU ARE NOT RETURNING THE LIST AND THE TEXT IS DUPLICATED)
I’m creating two new Listview.Builder() as quoted......as you can see in the code I put up there, I tried to create a new Listviewbuilder inside the same Expanded( (ie ta calling two Listview) it error in Child The argument for the named Parameter 'Child' was already specified. Try removing one of the named Arguments, or correcting one of the Names to Reference a Different named Parameter
– victor
If you can edit the answer from the top by putting how would two list inside the Expanded I really appreciate, I’m beginner I’m catching a lot.
– victor
In the code you posted there is only one Listview. Anyway, I edited the answer with the example as you suggested. Each Listview has its own Expanded. I suggest you take the official Flutter Cookbooks to study. Trying to do skipping steps can make it take longer to get what you want.
– Naslausky
Thank you so much for the help friend of vdd, but I put two expanded is the way you told me to put using two Expanded He just plays one list at the bottom of the other there the whole list does not get scrolable I need to give the scrool in a list only after scrolar the other list found it hard to understand i recorded the screen to take a look: https://drive.google.com/file/d/1MikRo_ZIk-4xTg2Ooo9OwFyowDut7Mrw/view?usp=sharing
– victor
Did you try the first way? With the
if(index<length)
, as requested in the question?– Naslausky
Friend, I gave CTRL+z here to go back the way I did that you quoted if(index<length) take a look at the edition I did in publishing how I did and how it is
– victor