diff --git a/Frontend/lib/mih_packages/mzansi_ai/package_tools/mih_ai_chat.dart b/Frontend/lib/mih_packages/mzansi_ai/package_tools/mih_ai_chat.dart index 657b7a5f..e4e43085 100644 --- a/Frontend/lib/mih_packages/mzansi_ai/package_tools/mih_ai_chat.dart +++ b/Frontend/lib/mih_packages/mzansi_ai/package_tools/mih_ai_chat.dart @@ -19,8 +19,9 @@ class MihAiChat extends StatefulWidget { State createState() => _MihAiChatState(); } -class _MihAiChatState extends State { +class _MihAiChatState extends State with WidgetsBindingObserver { final FlutterTts _flutterTts = FlutterTts(); + bool _isKeyboardVisible = false; Widget noMessagescDisplay() { return Center( @@ -191,14 +192,25 @@ class _MihAiChatState extends State { MzansiAiProvider aiProvider = context.read(); initTts(aiProvider); initStartQuestion(); + WidgetsBinding.instance.addObserver(this); } @override void dispose() { _flutterTts.stop(); + WidgetsBinding.instance.removeObserver(this); super.dispose(); } + @override + void didChangeMetrics() { + final bottomInset = WidgetsBinding + .instance.platformDispatcher.views.first.viewInsets.bottom; + setState(() { + _isKeyboardVisible = bottomInset > 0; + }); + } + @override Widget build(BuildContext context) { return Consumer( @@ -285,7 +297,7 @@ class _MihAiChatState extends State { ], ), ), - if (!hasHistory) noMessagescDisplay(), + if (!hasHistory && !_isKeyboardVisible) noMessagescDisplay(), ], ); },