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(() {
|
useEffect(() {
|
||||||
void syncSelectedCategoryWithScroll() {
|
Future<void> syncSelectedCategoryWithScroll() async {
|
||||||
|
await WidgetsBinding.instance.endOfFrame;
|
||||||
|
|
||||||
final viewport = scrollViewKey.currentContext
|
final viewport = scrollViewKey.currentContext
|
||||||
?.findRenderObject();
|
?.findRenderObject();
|
||||||
if (viewport is! RenderBox) return;
|
if (viewport is! RenderBox) return;
|
||||||
|
|
@ -80,14 +82,12 @@ class EmojiPicker extends HookConsumerWidget {
|
||||||
selectedCategory.value = selectedIndex;
|
selectedCategory.value = selectedIndex;
|
||||||
final chipContext = chipKeys[selectedIndex].currentContext;
|
final chipContext = chipKeys[selectedIndex].currentContext;
|
||||||
|
|
||||||
if (chipContext != null) {
|
if (chipContext != null && chipContext.mounted) {
|
||||||
unawaited(
|
await Scrollable.ensureVisible(
|
||||||
Scrollable.ensureVisible(
|
chipContext,
|
||||||
chipContext,
|
duration: Duration(milliseconds: 300),
|
||||||
duration: Duration(milliseconds: 300),
|
curve: Curves.easeInOut,
|
||||||
curve: Curves.easeInOut,
|
alignment: 0,
|
||||||
alignment: 0,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue