From 67044148f1995ebdc9a6db8854ad7e1655adbf44 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 16 Nov 2025 11:48:51 +0800 Subject: [PATCH] :lipstick: Fix chat input overlaps with message sometimes --- lib/screens/chat/room.dart | 1 + lib/widgets/thought/thought_shared.dart | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/screens/chat/room.dart b/lib/screens/chat/room.dart index d3b46e8d..9bb33d0c 100644 --- a/lib/screens/chat/room.dart +++ b/lib/screens/chat/room.dart @@ -619,6 +619,7 @@ class ChatRoomScreen extends HookConsumerWidget { top: 16, bottom: MediaQuery.of(context).padding.bottom + + 8 + inputHeight.value, // Leave space for chat input ), controller: scrollController, diff --git a/lib/widgets/thought/thought_shared.dart b/lib/widgets/thought/thought_shared.dart index f3feead7..2280e50e 100644 --- a/lib/widgets/thought/thought_shared.dart +++ b/lib/widgets/thought/thought_shared.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'dart:math' as math; import 'package:dio/dio.dart'; @@ -412,15 +413,19 @@ class ThoughtChatInterface extends HookConsumerWidget { attachedPosts: attachedPosts, ); + // Periodic height measurement for dynamic sizing useEffect(() { - WidgetsBinding.instance.addPostFrameCallback((_) { + final timer = Timer.periodic(const Duration(milliseconds: 50), (_) { final renderBox = inputKey.currentContext?.findRenderObject() as RenderBox?; if (renderBox != null) { - inputHeight.value = renderBox.size.height; + final newHeight = renderBox.size.height; + if (newHeight != inputHeight.value) { + inputHeight.value = newHeight; + } } }); - return null; + return timer.cancel; }, []); return Stack(