alphabet_scroll_view icon indicating copy to clipboard operation
alphabet_scroll_view copied to clipboard

Navigation by letter tapping is not working when itemExtent is not the exact row height

Open OlivierVoyer opened this issue 3 years ago • 2 comments

I was trying to have a dynamic height for the rows used in your AlphabetScrollView component.

My idea was to set a huge itemExtent value so that the rows would resize themselves automatically. Actually it did work.

However, it looks like your scrolling when a letter is tapped is based on that itemExtent value and so the scroll offset is not correct.

How could I have dynamic heights and the navigation working?

Thanks in advance

Code snippet:

AlphabetScrollView(
  list: list.map((e) => AlphaModel(e)).toList(),
  itemExtent: MediaQuery.of(context).size.height,
  unselectedTextStyle: TextStyle(
      fontSize: 18, fontWeight: FontWeight.normal, color: Colors.black),
  selectedTextStyle: TextStyle(
      fontSize: 20, fontWeight: FontWeight.bold, color: Colors.red),
  itemBuilder: (context, k, id) {
    return Padding(
      padding: const EdgeInsets.only(right: 40.0),
      child: Card(
        child: ListTile(
          title: Text('$id'),
          subtitle: Text(
            id.length.isOdd
                ? 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Feugiat vel tellus felis, ac phasellus sed massa. Feugiat vel tellus felis, ac phasellus sed masslis, ac phasellus sed massa.'
                : 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
          ),
          leading: Icon(Icons.person),
        ),
      ),
    );
    ;
  },
)
alphabet

OlivierVoyer avatar Aug 11 '21 13:08 OlivierVoyer

However, it looks like your scrolling when a letter is tapped is based on that itemExtent value and so the scroll offset is not correct.

You are right, And The issue looks like you have itemExtent set to screen height that is causing this issue. dynamic height is not supported as of now. I am sorry about that, I am planning to rework on this plugin soon to fix a bunch of those errors.

maheshj01 avatar Aug 11 '21 15:08 maheshj01

Thanks for your answer @maheshmnj . I will follow your progress then because it is a very promising package. Thanks for that

OlivierVoyer avatar Aug 12 '21 05:08 OlivierVoyer