Flutter : Listview Builder - Text

Asked

Viewed 292 times

-3

Good afternoon, you guys!

Could you help me with a question?

What am I doing:

  • I created a Listview. inside my body. As you can see I am passing an itemCount: data.length, because I created a List Dice that gathers all other Lists the return of my data[index] is:

      [Infracao{id: 20, conteudo: DIRIGIR veículo SEM possuir CNH}]
      [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
    
      [Fiscalizacao{id: 40, nome: VIADUTO,}]
    

And how I’m doing and my doubt

As you can see I need to compare if (dados[index] is Infracao) return ListaInfracao(dados[index] as Infracao); and so to others or be it returns me to LIST But beyond the list I’d like him to bring a Pedding calling a Text("Infringements") below returns the list and so on to the others.

Because of the way it is just giving a Return in the list and before giving the Return in the list I would like to return tmb a TEXT, below is picture of how it is currently as I would like it to be.

    body: Column(
      children: <Widget>[
        Expanded(
          child: ListView.builder(
            padding: EdgeInsets.all(10.0),
            itemCount: dados.length,
            itemBuilder: (BuildContext context, int index) {
              if (dados[index] is Infracao) 
                //AQUI RETORNARIA UM PEDDING TEXT();
                //DEPOIS A LISTA
                return ListaInfracao(dados[index] as Infracao);
              if (dados[index] is Anexo)
                return ListaAnexos(dados[index] as Anexo);
              else 
                return ListaFiscalizacao(dados[index] as Fiscalizacao);
            },
          ),
        ),
      ],
    ));

HOW YOU ARE CURRENTLY BRINGING THE LIST OF INFRINGEMENTS AND ATTACHMENTS TO PRINT

inserir a descrição da imagem aqui

HOW I WISH YOU WOULD RETURN

inserir a descrição da imagem aqui

  • Hey Victor beauty? How about using only one account to ask the questions? And try to finish one question before you start asking others! It’s always good to give feedback to those who are trying to help you.

  • I will close the other is that you commented to open another question for my doubt put in my other account the limit blocked and I need to take this doubt

1 answer

0


it is important that you know how to formulate your question, so that it is easy to understand what your need is, anyway let’s see if this can help you:

if (dados[index] is Infracao) 
   //AQUI RETORNARIA UM PEDDING TEXT();
   //DEPOIS A LISTA
   return ListaInfracao(dados[index] as Infracao);

If I understand your question correctly, Widget be it Infracao you need to return a widget ListaInfracao with a certain padding? If this the case you can accomplish this in several modes:

The simplest way would be to ultimate a Padding:

Then your Return would be:

return Padding(
   padding: const EdgeInsets.only(top: ALTURA_DESEJADA),
   child: ListaInfracao(dados[index] as Infracao);
);

Or you create your list in to a Container:

return Container(
   padding: const EdgeInsets.only(top: ALTURA_DESEJADA),
   child: ListaInfracao(dados[index] as Infracao);
);

Better organize your code, you are creating 3 different lists between them, within a List, so you can practically have 3 Listviews within a 1 Listview, why not create directly the Listviews you need? If all Listviews are similar (at least from the image it seems so), why not create a single widget, which gets its Energy list and creates the view?

  • Actually he wants to make a grouped list, but apparently he doesn’t want to go after the most basic things in the language... Like you, I’ve already given him a path in another question of his own (This one here) and I have also indicated a package of its own for what he wishes... It is lack of commitment on his part to seek to understand before applying.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.