I'd like to have a ListView of columns that could scroll horizontally and in each of those columns a ListView of rows that could scroll vertically.
Here's the code that I wrote:
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
"AppName",
textAlign: TextAlign.center,
),
Expanded(
//This is the first ListView, the itemBuilder returns a Column
child: ListView.separated(
scrollDirection: Axis.horizontal,
controller: scrollController,
itemCount: filesProvider.directories.length,
itemBuilder: (BuildContext context, int index) {
return buildColumn(context, index, filesProvider);
},
separatorBuilder: (BuildContext context, int index) {
return SizedBox(
width: 30,
);
},
),
),
],
),
);
}
Column buildColumn(BuildContext context, int index, FilesProvider provider) {
return Column(
children: [
Text(
"Column "+index,
textAlign: TextAlign.center,
),
Expanded(
//This is the second ListView, the itemBuilder returns a Row
child: ListView.separated(
scrollDirection: Axis.vertical,
controller: scrollController,
itemCount: (provider.dirNames[index].length / colonnePerTipo).round(),
itemBuilder: (BuildContext context, int rowIndex) {
return buildRow(context, rowIndex, provider);
},
separatorBuilder: (BuildContext context, int rowIndex) {
return SizedBox(
width: 10,
);
},
),
),
],
);
}
Row buildRow(BuildContext context, int index, FilesProvider provider) {
List<Widget> sizedBoxes = [];
for (int i = 0; i < buttonForRow; i++) {
sizedBoxes.add(
SizedBox(
width: 20,
child: ElevatedButton(
child: Text("Button"),
),
),
);
}
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: sizedBoxes,
);
}
It seems fine to me but when I run it I receive this error:
======== Exception caught by rendering library =====================================================
The following assertion was thrown during paint():
RenderBox was not laid out: RenderRepaintBoundary#29de6 relayoutBoundary=up2 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1929 pos 12: 'hasSize'
I don't understand what the problem could be. Can someone help me?