简体   繁体   中英

Flutter ReorderableListView inside an ExpansionTile

I need a reorderable list inside an expansion tile, but the ReorderableListView doesn't work unless it's put into a fixed size container or it gets the following errors.

BoxConstraints forces an infinite height.
The relevant error-causing widget was
ReorderableListView 

-

RenderBox was not laid out: RenderStack#77d94 relayoutBoundary=up18 NEEDS-PAINT 

NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1687 pos 12: 'hasSize'
The relevant error-causing widget was
ReorderableListView

-

RenderBox was not laid out: _RenderTheatre#778cd relayoutBoundary=up17 NEEDS-PAINT 

NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1687 pos 12: 'hasSize'
The relevant error-causing widget was
    ExpansionTile-[Thing]

And if I put it inside a fixed box I get the following error when trying to move items.

The following assertion was thrown while handling a gesture:
ScrollController attached to multiple scroll views.
'package:flutter/src/widgets/scroll_controller.dart':
Failed assertion: line 111 pos 12: '_positions.length == 1'

I ended up using this awesome package to do it instead of the very limited ReorderableListView.

Then I used the ReorderableColumn widget and it works great. The Flutter team really should update the ReorderableListView so that it's not so limited.

Here is an example of working code:

body: Column(
        children: <Widget>[
          Text('哈哈哈'),
          Expanded(
              child: ReorderableListView(
            header: cellManageHead(),
            children: list.map((e) => cellManage(e)).toList(),
            onReorder: _onReorder,
          ))
        ],
      ),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM