wait for end of frame before highlighting categories
Fixes an issue where category highlights could be one scroll old
This commit is contained in:
parent
e4602b65f8
commit
072a366f43
1 changed files with 9 additions and 9 deletions
|
|
@ -58,7 +58,9 @@ class EmojiPicker extends HookConsumerWidget {
|
|||
);
|
||||
|
||||
useEffect(() {
|
||||
void syncSelectedCategoryWithScroll() {
|
||||
Future<void> syncSelectedCategoryWithScroll() async {
|
||||
await WidgetsBinding.instance.endOfFrame;
|
||||
|
||||
final viewport = scrollViewKey.currentContext
|
||||
?.findRenderObject();
|
||||
if (viewport is! RenderBox) return;
|
||||
|
|
@ -80,14 +82,12 @@ class EmojiPicker extends HookConsumerWidget {
|
|||
selectedCategory.value = selectedIndex;
|
||||
final chipContext = chipKeys[selectedIndex].currentContext;
|
||||
|
||||
if (chipContext != null) {
|
||||
unawaited(
|
||||
Scrollable.ensureVisible(
|
||||
chipContext,
|
||||
duration: Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
alignment: 0,
|
||||
),
|
||||
if (chipContext != null && chipContext.mounted) {
|
||||
await Scrollable.ensureVisible(
|
||||
chipContext,
|
||||
duration: Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
alignment: 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue