BUG: Remove hint when keyboard is open
This commit is contained in:
@@ -19,8 +19,9 @@ class MihAiChat extends StatefulWidget {
|
|||||||
State<MihAiChat> createState() => _MihAiChatState();
|
State<MihAiChat> createState() => _MihAiChatState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MihAiChatState extends State<MihAiChat> {
|
class _MihAiChatState extends State<MihAiChat> with WidgetsBindingObserver {
|
||||||
final FlutterTts _flutterTts = FlutterTts();
|
final FlutterTts _flutterTts = FlutterTts();
|
||||||
|
bool _isKeyboardVisible = false;
|
||||||
|
|
||||||
Widget noMessagescDisplay() {
|
Widget noMessagescDisplay() {
|
||||||
return Center(
|
return Center(
|
||||||
@@ -191,14 +192,25 @@ class _MihAiChatState extends State<MihAiChat> {
|
|||||||
MzansiAiProvider aiProvider = context.read<MzansiAiProvider>();
|
MzansiAiProvider aiProvider = context.read<MzansiAiProvider>();
|
||||||
initTts(aiProvider);
|
initTts(aiProvider);
|
||||||
initStartQuestion();
|
initStartQuestion();
|
||||||
|
WidgetsBinding.instance.addObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_flutterTts.stop();
|
_flutterTts.stop();
|
||||||
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeMetrics() {
|
||||||
|
final bottomInset = WidgetsBinding
|
||||||
|
.instance.platformDispatcher.views.first.viewInsets.bottom;
|
||||||
|
setState(() {
|
||||||
|
_isKeyboardVisible = bottomInset > 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Consumer<MzansiAiProvider>(
|
return Consumer<MzansiAiProvider>(
|
||||||
@@ -285,7 +297,7 @@ class _MihAiChatState extends State<MihAiChat> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!hasHistory) noMessagescDisplay(),
|
if (!hasHistory && !_isKeyboardVisible) noMessagescDisplay(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user