@@ -288,12 +288,13 @@ class _ContentInput extends StatefulWidget {
288
288
State <_ContentInput > createState () => _ContentInputState ();
289
289
}
290
290
291
- class _ContentInputState extends State <_ContentInput > {
291
+ class _ContentInputState extends State <_ContentInput > with WidgetsBindingObserver {
292
292
@override
293
293
void initState () {
294
294
super .initState ();
295
295
widget.controller.addListener (_contentChanged);
296
296
widget.focusNode.addListener (_focusChanged);
297
+ WidgetsBinding .instance.addObserver (this );
297
298
}
298
299
299
300
@override
@@ -313,6 +314,7 @@ class _ContentInputState extends State<_ContentInput> {
313
314
void dispose () {
314
315
widget.controller.removeListener (_contentChanged);
315
316
widget.focusNode.removeListener (_focusChanged);
317
+ WidgetsBinding .instance.removeObserver (this );
316
318
super .dispose ();
317
319
}
318
320
@@ -337,6 +339,31 @@ class _ContentInputState extends State<_ContentInput> {
337
339
store.typingNotifier.stoppedComposing ();
338
340
}
339
341
342
+ @override
343
+ void didChangeAppLifecycleState (AppLifecycleState state) {
344
+ switch (state) {
345
+ case AppLifecycleState .hidden:
346
+ case AppLifecycleState .paused:
347
+ // Transition to either of these states signals that
348
+ // > [the] application is not currently visible to the user, and not
349
+ // > responding to user input.
350
+ final store = PerAccountStoreWidget .of (context);
351
+ store.typingNotifier.stoppedComposing ();
352
+ case AppLifecycleState .detached:
353
+ // > The application defaults to this state before it initializes, and
354
+ // > can be in this state (applicable on Android, iOS, and web) after
355
+ // > all views have been detached.
356
+ // At the point, the compose box might not exist, so it is irrelevant
357
+ // to the composing session.
358
+ case AppLifecycleState .inactive:
359
+ // > At least one view of the application is visible, but none have
360
+ // > input focus. The application is otherwise running normally.
361
+ // For example, we expect this state when the user is selecting a file
362
+ // to upload.
363
+ case AppLifecycleState .resumed:
364
+ }
365
+ }
366
+
340
367
@override
341
368
Widget build (BuildContext context) {
342
369
ColorScheme colorScheme = Theme .of (context).colorScheme;
0 commit comments