diff --git a/lib/screens/thought/think.dart b/lib/screens/thought/think.dart index 3131c9c1..0b04b745 100644 --- a/lib/screens/thought/think.dart +++ b/lib/screens/thought/think.dart @@ -102,7 +102,7 @@ class ThoughtScreen extends HookConsumerWidget { } catch (e) { showSnackBar('Failed to retry billing'); } - hideLoadingModal(context); + if (context.mounted) hideLoadingModal(context); }, [context, ref], ); diff --git a/lib/screens/thought/think_sheet.dart b/lib/screens/thought/think_sheet.dart index f2b9572b..fd0c6208 100644 --- a/lib/screens/thought/think_sheet.dart +++ b/lib/screens/thought/think_sheet.dart @@ -62,7 +62,7 @@ class ThoughtSheet extends HookConsumerWidget { } catch (e) { showSnackBar('Failed to retry billing'); } - hideLoadingModal(context); + if (context.mounted) hideLoadingModal(context); }, [context, ref], ); diff --git a/lib/widgets/thought/thought_shared.dart b/lib/widgets/thought/thought_shared.dart index 6decfb91..f3feead7 100644 --- a/lib/widgets/thought/thought_shared.dart +++ b/lib/widgets/thought/thought_shared.dart @@ -401,6 +401,9 @@ class ThoughtChatInterface extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + final inputKey = useMemoized(() => GlobalKey()); + final inputHeight = useState(80.0); + final chatState = useThoughtChat( ref, initialThoughts: initialThoughts, @@ -409,6 +412,17 @@ class ThoughtChatInterface extends HookConsumerWidget { attachedPosts: attachedPosts, ); + useEffect(() { + WidgetsBinding.instance.addPostFrameCallback((_) { + final renderBox = + inputKey.currentContext?.findRenderObject() as RenderBox?; + if (renderBox != null) { + inputHeight.value = renderBox.size.height; + } + }); + return null; + }, []); + return Stack( children: [ // Thoughts list @@ -425,7 +439,8 @@ class ThoughtChatInterface extends HookConsumerWidget { top: 16, bottom: MediaQuery.of(context).padding.bottom + - 80, // Leave space for thought input + 56 + + inputHeight.value, // Leave space for thought input ), reverse: true, itemCount: @@ -492,6 +507,7 @@ class ThoughtChatInterface extends HookConsumerWidget { child: Container( constraints: BoxConstraints(maxWidth: 640), child: ThoughtInput( + key: inputKey, messageController: chatState.messageController, isStreaming: chatState.isStreaming.value, onSend: chatState.sendMessage,