fix: 评论回复State对象失效

This commit is contained in:
orz12
2024-02-26 13:43:30 +08:00
parent 1e47096ffa
commit c1a66fd1d5

View File

@@ -111,18 +111,20 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
super.didChangeMetrics(); super.didChangeMetrics();
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
// 键盘高度 // 键盘高度
final viewInsets = EdgeInsets.fromViewPadding( if (mounted) {
View.of(context).viewInsets, View.of(context).devicePixelRatio); final viewInsets = EdgeInsets.fromViewPadding(
_debouncer.run(() { View.of(context).viewInsets, View.of(context).devicePixelRatio);
if (mounted) { _debouncer.run(() {
if (keyboardHeight == 0 && emoteHeight == 0) { if (mounted) {
setState(() { if (keyboardHeight == 0 && emoteHeight == 0) {
emoteHeight = keyboardHeight = setState(() {
keyboardHeight == 0.0 ? viewInsets.bottom : keyboardHeight; emoteHeight = keyboardHeight =
}); keyboardHeight == 0.0 ? viewInsets.bottom : keyboardHeight;
});
}
} }
} });
}); }
}); });
} }
@@ -131,6 +133,7 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
WidgetsBinding.instance.removeObserver(this); WidgetsBinding.instance.removeObserver(this);
_replyContentController.dispose(); _replyContentController.dispose();
replyContentFocusNode.removeListener(() {}); replyContentFocusNode.removeListener(() {});
replyContentFocusNode.dispose();
super.dispose(); super.dispose();
} }