try to address context issues after inactivity
This commit is contained in:
+31
-21
@@ -86,6 +86,8 @@ class ViewTabSheetWidget extends HookConsumerWidget {
|
|||||||
final scrolledTo = useRef(0.0);
|
final scrolledTo = useRef(0.0);
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
|
||||||
final header = headerKey.currentContext?.findRenderObject();
|
final header = headerKey.currentContext?.findRenderObject();
|
||||||
final text = textFieldKey.currentContext?.findRenderObject();
|
final text = textFieldKey.currentContext?.findRenderObject();
|
||||||
|
|
||||||
@@ -96,14 +98,16 @@ class ViewTabSheetWidget extends HookConsumerWidget {
|
|||||||
|
|
||||||
final relative = totalHeight / MediaQuery.of(context).size.height;
|
final relative = totalHeight / MediaQuery.of(context).size.height;
|
||||||
|
|
||||||
if (draggableScrollableController.size < relative &&
|
if (relative >= 0 && relative <= 1) {
|
||||||
relative > scrolledTo.value) {
|
if (draggableScrollableController.size < relative &&
|
||||||
await draggableScrollableController.animateTo(
|
relative > scrolledTo.value) {
|
||||||
relative,
|
await draggableScrollableController.animateTo(
|
||||||
duration: const Duration(milliseconds: 150),
|
relative,
|
||||||
curve: Curves.easeInOut,
|
duration: const Duration(milliseconds: 150),
|
||||||
);
|
curve: Curves.easeInOut,
|
||||||
scrolledTo.value = relative;
|
);
|
||||||
|
scrolledTo.value = relative;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,22 +117,28 @@ class ViewTabSheetWidget extends HookConsumerWidget {
|
|||||||
});
|
});
|
||||||
|
|
||||||
final bottomInsets = useRef(0.0);
|
final bottomInsets = useRef(0.0);
|
||||||
useEffect(() {
|
useEffect(
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
() {
|
||||||
final diff =
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
((MediaQuery.of(context).viewInsets.bottom / 2) /
|
final diff =
|
||||||
MediaQuery.of(context).size.height) -
|
((MediaQuery.of(context).viewInsets.bottom / 2) /
|
||||||
bottomInsets.value;
|
MediaQuery.of(context).size.height) -
|
||||||
|
bottomInsets.value;
|
||||||
|
|
||||||
draggableScrollableController.jumpTo(
|
draggableScrollableController.jumpTo(
|
||||||
draggableScrollableController.size + diff,
|
draggableScrollableController.size + diff,
|
||||||
);
|
);
|
||||||
|
|
||||||
bottomInsets.value += diff;
|
bottomInsets.value += diff;
|
||||||
});
|
});
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}, [MediaQuery.of(context).viewInsets.bottom]);
|
},
|
||||||
|
[
|
||||||
|
MediaQuery.of(context).viewInsets.bottom,
|
||||||
|
MediaQuery.of(context).size.height,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
return NestedScrollView(
|
return NestedScrollView(
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
|||||||
Reference in New Issue
Block a user