Dynamically adjust item height in Flutter Timeline based on ExpandableText content

26 Views Asked by At

I'm working on implementing a timeline widget in my Flutter app, where each item in the timeline contains some content, including potentially long text wrapped inside an ExpandableText widget. The issue I'm facing is that when the ExpandableText is expanded to show the full content, it extends beyond the predefined height (itemExtentBuilder) of the timeline item, causing overflow issues.

Here's a simplified version of my code:

TimelineTileBuilder.connected(
  // Other properties...
  itemExtentBuilder: (_, index) {
    // Calculate the height dynamically based on content
    // This is where I'm facing issues
  },
  contentsBuilder: (context, index) {
    return Container(
      // Other properties...
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // Other widgets...
          Flexible(
            child: SingleChildScrollView(
              child: ExpandableText(
                // Long text content...
              ),
            ),
          ),
        ],
      ),
    );
  },
);

I don't know how to access the expanded height of the ExpandableText to adjust the item height accordingly.

Is there a way to dynamically update the itemExtentBuilder based on the expanded height of the ExpandableText or any other approach to handle this issue effectively?

0

There are 0 best solutions below