Fintasys / emoji_picker_flutter

A Flutter package that provides an Emoji picker widget with 1500+ emojis in 8 categories.
MIT License
154 stars 114 forks source link

ScrollController not attached to any scroll views. 'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 157 pos 12: '_positions.isNotEmpty' #196

Closed ankittiwari25 closed 3 months ago

ankittiwari25 commented 3 months ago

in initState method you are adding addListener of textEditingController and and passing _scrollToCursorAfterTextChange method at that time you are using animateTo method.At that time it showing this error.

Screenshot 2024-03-21 at 18 06 28
ankittiwari25 commented 3 months ago

Just update _scrollToCursorAfterTextChange method to below code it will work fine.

void scrollToCursorAfterTextChange() { if (widget.scrollController != null) { final scrollController = widget.scrollController!; WidgetsBinding.instance.addPostFrameCallback(() { if (scrollController.hasClients) scrollController.animateTo( scrollController.position.maxScrollExtent, duration: const Duration(milliseconds: 200), curve: Curves.ease, ); }); } }

Fintasys commented 3 months ago

Thanks for reporting, I fixed the issue with version 2.1.1 which I just have released 🙏

ankittiwari25 commented 3 months ago

@Fintasys thanks buddy for fixing this issue