-1
Hello, all the Listview of my application in Flutter if add more than 3 items occurs to Exception below:
I/flutter (13259): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ I/flutter (13259): The following assertion was thrown building I/flutter (13259): Rawgesturedetector-[Labeledglobalkey#fd1f4](state: I/flutter (13259): Rawgesturedetectorstate#a263f(Estures: , behavior: Paque)): I/flutter (13259): 'package:flutter/src/Rendering/sliver_multi_box_adaptor.Dart': Failed assertion: line 263 pos 16: I/flutter (13259): 'Child == null || indexof(Child) > index': is not true.
After this Exception, I try to go to another screen and the following error appears in my Listview, then expands to the whole screen!
I/flutter ( 7826): Another Exception was thrown: 'package:flutter/src/widgets/framework.Dart': Failed assertion: line 1772 pos 12: '_Elements.contains(element)': is not true.
Someone’s been through this and can help me?
Widget Code:
 @override
  void dispose() {
    listViewController.removeListener(_scrollListener);
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomPadding: true,
      key: _scaffoldstate,
     body: (_listaTela.length == 0)
      ? new AppLayout(
        navBar: NavBar(
          title: "$_titulo",
        ),
        widget: Column(
          //crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.only(
                top: 15.0,
              ),
              child: Row(
                children: <Widget>[
                  Padding(
                    padding: const EdgeInsets.only(left: 35.0, right: 15.0),
                    child: Container(
                        width: 45.0,
                        height: 45.0,
                        decoration: BoxDecoration(
                            border: Border.all(width: 1.0, color: Colors.grey),
                            shape: BoxShape.circle),
                        child: new Icon(Icons.shopping_basket)),
                  ),
                  Text("$_titulo",
                      style: TextStyle(
                          fontSize: 16.0, fontWeight: FontWeight.w600))
                ],
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(
                  left: 25.0, right: 25.0, top: 10.0, bottom: 15.0),
              child: Divider(
                height: 1.0,
              ),
            ),
            // sem itens
            Offstage(
              offstage: !_semItens,
              child: Column(
                children: <Widget>[
                  Icon(
                    Icons.list,
                    size: 50.0,
                  ),
                  Text('Sem itens'),
                  FlatButton(
                    onPressed: () {
                      _resetLista();
                    },
                    child: Text('Atualizar'),
                  )
                ],
              ),
            ),
            // loading
            Offstage(
              offstage: !_ocupado,
              child: Center(child: CircularProgressIndicator()),
            ),
                  ],
                ),
              ) 
              : new AppLayout(
        navBar: NavBar(
          title: "$_titulo",
        ),
        widget: Column(
          //crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.only(
                top: 15.0,
              ),
              child: Row(
                children: <Widget>[
                  Padding(
                    padding: const EdgeInsets.only(left: 35.0, right: 15.0),
                    child: Container(
                        width: 45.0,
                        height: 45.0,
                        decoration: BoxDecoration(
                            border: Border.all(width: 1.0, color: Colors.grey),
                            shape: BoxShape.circle),
                        child: new Icon(Icons.shopping_basket)),
                  ),
                  Text("$_titulo",
                      style: TextStyle(
                          fontSize: 16.0, fontWeight: FontWeight.w600))
                ],
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(
                  left: 25.0, right: 25.0, top: 10.0, bottom: 15.0),
              child: Divider(
                height: 1.0,
              ),
            ),
            // sem itens
            Offstage(
              offstage: !_semItens,
              child: Column(
                children: <Widget>[
                  Icon(
                    Icons.list,
                    size: 50.0,
                  ),
                  Text('Sem itens'),
                  FlatButton(
                    onPressed: () {
                      _resetLista();
                    },
                    child: Text('Atualizar'),
                  )
                ],
              ),
            ),
            // loading
            Offstage(
 Flexible(
              child: ClipRect(
                child: RefreshIndicator(
                  onRefresh: _resetLista,
                  child: ListView(
                    padding: const EdgeInsets.only(
                      left: 4.0,
                      right: 4.0,
                    ),
                      controller: listViewController,
                      children: _listaTela.map((it) {
                        return Dismissible(
                          background: Container(color: Colors.red,),
                          key: ValueKey("remover"),
                          onDismissed: (direction){
                            setState((){
                              _removerItem(it);
                            });
                          },
                          child: ListTile(
                          onTap: () {
                            _itemSel(it, _listaTela.indexOf(it));
                          },
                          title: Row(
                            children: <Widget>[
                              Padding(
                                  padding: EdgeInsets.only(right: 12.0),
                                  child: Container(
                                    height: 40.0,
                                    width: 50.0,
                                    child: Icon(
                                      Icons.label,
                                      color: Colors.white,
                                      size: 30.0,
                                    ),
                                    color: Colors.blueGrey,
                                  )),
                              Flexible(
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: <Widget>[
                                    Column(
                                      crossAxisAlignment:
                                          CrossAxisAlignment.start,
                                      children: <Widget>[
                                        Padding(
                                          padding: const EdgeInsets.only(
                                              bottom: 4.0),
                                          child: Text(
                                            it.produto.descricao.toString(),
                                            textAlign: TextAlign.left,
                                            style: TextStyle(
                                                fontSize: 15.0,
                                                letterSpacing: 1.0,
                                                fontWeight: FontWeight.bold),
                                            maxLines: 1,
                                            overflow: TextOverflow.ellipsis,
                                          ),
                                        ),
                                        Padding(
                                          padding: const EdgeInsets.only(
                                              bottom: 4.0),
                                          child: Text(
                                            it.quantidade.toString(),
                                            textAlign: TextAlign.left,
                                            style: TextStyle(
                                              fontSize: 15.0,
                                              letterSpacing: 1.0,
                                            ),
                                            maxLines: 1,
                                            overflow: TextOverflow.ellipsis,
                                          ),
                                        ),
                                      ],
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        )
                        );
                      }).toList()),
                ),
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(bottom: 8.0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Padding(
                    padding: const EdgeInsets.all(10.0),
                    child: Text(
                      '$_lblTot',
                      style: const TextStyle(color: Colors.grey),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
      floatingActionButton: SpeedDial(
        animatedIcon: AnimatedIcons.menu_close,
        children: [
          SpeedDialChild(
            child: Icon(Icons.add),
            label: "Adicionar item",
            onTap: () {
              _add();
            }, 
            ),
            SpeedDialChild(
            child: Icon(Icons.send),
            label: "Enviar pedido",
            backgroundColor: Colors.green,
            onTap: () {
              _enviar();
            } 
            )
        ],
      ),
    );
  }
}

Show the code you made.
– robsonp
Without the code it’s not possible to analyze
– Julio Henrique Bitencourt
I’ve added the Listview code, thanks in advance.
– Dener Portela
It would be interesting an example that it was possible to reproduce, take your code and execute.. If it is not possible to pass, I would recommend removing Widget by Widget from the tree to identify where the problem is.
– Julio Henrique Bitencourt
@Juliohenriquebitencourt I will create a code that to reproduce, thank you.
– Dener Portela
@Denerportela show! It will facilitate the analysis.
– Julio Henrique Bitencourt
@Juliohenriquebitencourt I put the project on Github: https://github.com/denerportela/flutter_listview_bug_itens 1. Download the project. 2. Run. 3. Click the Floating Menu Button 4. Click the + After the 3rd click the error will appear!
– Dener Portela
If the answer helped/answered your question, mark it as accepted.
– Julio Henrique Bitencourt