From e3261999237659eead171caf16979c690732d0d4 Mon Sep 17 00:00:00 2001 From: Bruno Leroux Date: Fri, 1 Sep 2023 11:24:33 +0200 Subject: [PATCH] Add more documentation for SystemChannels.keyboard getKeyboardState (#133663) ## Description This PR adds some documentation to SystemChannels.keyboard getKeyboardState. This method was added in https://github.com/flutter/flutter/pull/122885. ## Related Issue Fixes https://github.com/flutter/flutter/issues/132938. ## Tests Documentation only. --- packages/flutter/lib/src/services/hardware_keyboard.dart | 4 ++++ packages/flutter/lib/src/services/system_channels.dart | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/packages/flutter/lib/src/services/hardware_keyboard.dart b/packages/flutter/lib/src/services/hardware_keyboard.dart index 7c2af2bd84..ee994306f4 100644 --- a/packages/flutter/lib/src/services/hardware_keyboard.dart +++ b/packages/flutter/lib/src/services/hardware_keyboard.dart @@ -532,6 +532,10 @@ class HardwareKeyboard { } /// Query the engine and update _pressedKeys accordingly to the engine answer. + // + /// Both the framework and the engine maintain a state of the current pressed + /// keys. There are edge cases, related to startup and restart, where the framework + /// needs to resynchronize its keyboard state. Future syncKeyboardState() async { final Map? keyboardState = await SystemChannels.keyboard.invokeMapMethod( 'getKeyboardState', diff --git a/packages/flutter/lib/src/services/system_channels.dart b/packages/flutter/lib/src/services/system_channels.dart index 3a65302a2d..5311d36c7c 100644 --- a/packages/flutter/lib/src/services/system_channels.dart +++ b/packages/flutter/lib/src/services/system_channels.dart @@ -503,6 +503,10 @@ abstract final class SystemChannels { /// represents a pressed keyboard key. The entry key is the physical /// key ID and the entry value is the logical key ID. /// + /// Both the framework and the engine maintain a state of the current + /// pressed keys. There are edge cases, related to startup and restart, + /// where the framework needs to resynchronize its keyboard state. + /// /// See also: /// /// * [HardwareKeyboard.syncKeyboardState], which uses this channel to synchronize