rickypid / flutter_expandable_table

A Flutter widget for create an expandable table with header and first column fixed.
https://pub.dev/packages/flutter_expandable_table
BSD 3-Clause "New" or "Revised" License
38 stars 28 forks source link

RangeError (index): Invalid value: Valid value range is empty: 0 #11

Closed jalvespinto closed 1 year ago

jalvespinto commented 1 year ago

For the tablebody I keep getting this error in the _buildBodyColumns method because the visibleColumn is empty at first.

for (Widget cell in cells) {
        cellsRow.add(ExpandableTableCell(
          child: cell,
          height: row.height,
          width: ExpandableTableData.of(context).cellWidth,
          horizontalExpanded:
              ExpandableTableData.of(context).visibleColumn[x] == true,
          verticalExpanded: rowParent != null ? rowParent.isExpanded : true,
        ));
        x++;
      }

If I hot reload the emulator after going to the page it works.

sithu-aung commented 1 year ago

I am facing the same error too. Haven't any idea to solve this ?

nachiketghelani54 commented 1 year ago

basically i have data and data contains sub data. when i click on data then sub data is showing but when subdata is empty then the data column is removed automatically from header. so thats why range error is generating. so this is my problem please give me solution for this. for more information pls check the attachment. please check this and give me solution for this.

attachment

thank you all in advance.

madebyframe commented 1 year ago

For the tablebody I keep getting this error in the _buildBodyColumns method because the visibleColumn is empty at first.

for (Widget cell in cells) {
        cellsRow.add(ExpandableTableCell(
          child: cell,
          height: row.height,
          width: ExpandableTableData.of(context).cellWidth,
          horizontalExpanded:
              ExpandableTableData.of(context).visibleColumn[x] == true,
          verticalExpanded: rowParent != null ? rowParent.isExpanded : true,
        ));
        x++;
      }

I noticed that this work-around seems to work by adding a sanity check on the offending index value:

 for (Widget cell in cells) {
        cellsRow.add(ExpandableTableCell(
          child: cell,
          height: row.height,
          width: ExpandableTableData.of(context).cellWidth,
          horizontalExpanded:
              ExpandableTableData.of(context).visibleColumn.asMap().containsKey(x) &&
              ExpandableTableData.of(context).visibleColumn[x] == true,
          verticalExpanded: rowParent != null ? rowParent.isExpanded : true,
        ));
nachiketghelani54 commented 1 year ago

@madebyframe

we created header data list statically based on data. we can add data to header data dynamically but we can not able to add header children dynamically and thats why range error is generating.

lottoforecaster commented 1 year ago

I am facing the same error too. Haven't any idea to solve this ?

+1

For my case had to downgrade flutter version to 3.3.2 as work-around

rickypid commented 1 year ago

Hi everyone,

I'm sorry for the problem encountered but I didn't have time to dedicate to this project, finally in a few weeks I will release a new 2.0 version which will contain some requests that have been made to me, also this one #9, both for row height and column width.

I will notify you as soon as it is published and ask for some feedback.

Thank you.

rickypid commented 1 year ago

Hi everyone, here you can find the new release v2.0.0-beta.1 (in beta) with some improvements and improved/added features.

It requires some adaptation from the previous 1.x version, but it was necessary to improve the code base.

Thank you for waiting, I hope you will give me some feedback. 😄

rickypid commented 1 year ago

Not to sound ungrateful but come on..don't make a package is it isn't working Was pulling my hair out All day Wondering why this isn't working then I finally came here

Hi @somtobro,

I'm sorry for the problem you had, are you referring to the latest release 2.0.0-beta.1 or to the previous release 1.1.1? the previous version works up to Flutter 3.3.10, we use it on several installations without problems. recently following the open issues I decided to completely review the code and solve the problem, I had little time and I only managed to release the new release yesterday. I don't want to be argumentative, but the project is Open Source, so if you encounter a problem and you have better solutions than the ones I proposed, I'm happy to receive your pr to fix the problem.

I await your feedback 😜