For some time now (years), Flutter has had two key event systems implemented. The new system reached parity with the old platform-specific raw key event system, and the raw system will be removed. To prepare for that, the Flutter APIs that use the old system are being modified, and for a select few of them we have decided to make breaking changes in the API in order to preserve the quality of the API.
Original behavior
In the original key event subsystem handling each platform's quirks in the framework and in client apps caused overly complex code, and the old system didn't properly represent the true state of key events on the system.
New behavior
Summary of APIs that have been affected:
- Who is affected
- affected:
- Practical impact
- Behaviour or API differences that can break builds or change runtime behaviour.
- What action should I take?
- Follow the official migration guide below, update affected call sites, run `dart fix --apply` where a fix is available, then run your tests.
Before and after (from the official guide)
| 1 | class MyActivator extends ShortcutActivator { | |
| 2 | @override | |
| 3 | − | bool accepts(RawKeyEvent event, RawKeyboard state) { |
| 4 | // ... (your implementation here) | |
| 5 | returns false; | |
| 6 | } | |
| 7 | // ... | |
| 8 | } |
| 1 | class MyActivator extends ShortcutActivator { | |
| 2 | @override | |
| 3 | + | bool accepts(KeyEvent event, HardwareKeyboard state) { |
| 4 | // ... (your implementation here) | |
| 5 | returns false; | |
| 6 | } | |
| 7 | // ... | |
| 8 | } |
Raw before / after
class MyActivator extends ShortcutActivator {
@override
bool accepts(RawKeyEvent event, RawKeyboard state) {
// ... (your implementation here)
returns false;
}
// ...
}class MyActivator extends ShortcutActivator {
@override
bool accepts(KeyEvent event, HardwareKeyboard state) {
// ... (your implementation here)
returns false;
}
// ...
}Official migration guide (excerpt, © The Flutter Authors, CC BY 3.0)
APIs provided by the Flutter framework are already migrated. Migration is needed only if you're using any of the methods listed in the previous section.
Migrating your APIs that use ShortcutActivator or its subclasses.
Pass a KeyEvent instead of a RawKeyEvent to ShortcutActivator.accepts.
This may mean switching where you get your key events from. Depending on where
you get them, this can either mean switching to using Focus.onKeyEvent instead
of Focus.onKey, or a similar change if using FocusScope, FocusNode or
FocusScopeNode.
If you're using a RawKeyboardListener, switch to using a
KeyboardListener instead. If you're accessing RawKeyboard directly, use
HardwareKeyboard instead. You'll find that there are non-raw equivalents for
all of the key event sources.
Migrating your APIs that extend ShortcutActivator
The ShortcutActivator.accepts method was modified to take a KeyEvent and a
HardwareKeyboard instead of a RawKeyEvent and RawKeyboard.
Before:
class MyActivator extends ShortcutActivator {
@override
bool accepts(RawKeyEvent event, RawKeyboard state) {
// ... (your implementation here)
returns false;
}
// ...
}After:
class MyActivator extends ShortcutActivator {
@override
bool accepts(KeyEvent event, HardwareKeyboard state) {
// ... (your implementation here)
returns false;
}
// ...
}Migrating your APIs that extend ShortcutManager
The ShortcutManager class was modified to take KeyEvents in handleKeypress
instead of RawKeyEvents. One difference in the two APIs is that repeated keys
are determined differently. In the RawKeyEvent case, the repeat member
indicated a repeat, but in RawKeyEvent code, the event is a different type
(KeyRepeatEvent).
Before:
class _MyShortcutManager extends ShortcutManager {
@override
KeyEventResult handleKeypress(BuildContext context, RawKeyEvent event) {
if (event is! RawKeyDownEvent) {
return KeyEventResult.ignored;
}
if (event.repeat) {
// (Do something with repeated keys.)
}
// ... (your implementation here)
return KeyEventResult.handled;
}
}After:
class _MyShortcutManager extends ShortcutManager {
@override
KeyEventResult handleKeypress(BuildContext context, KeyEvent event) {
if (event is! KeyDownEvent && event is! KeyRepeatEvent) {
return KeyEventResult.ignored;
}
if (event is KeyRepeatEvent) {
// (Do something with repeated keys.)
}
// ... (your implementation here)
return KeyEventResult.handled;
}
}AI_PROVIDER (for example to openai-compatible with a local Ollama or LM Studio endpoint) to enable grounded explanations. Everything else on this page works without an AI provider.Listed in the official breaking-changes index (docs.flutter.dev/release/breaking-changes).
An official announcement or migration guide documents an intended behaviour or API change. A verified source change (git diff) shows code changed but does not by itself prove a public API is breaking. AI interpretations are labelled and never used to classify a change.
- Official migration guide
- KeyEvent
- HardwareKeyboard
- ShortcutActivator
- ShortcutManager
- RawKeyEvent and RawKeyboard, et al should be deprecated and removed (Issue 136419)
- Prepare ShortcutActivator and ShortcutManager to migrate to KeyEvent from RawKeyEvent
- Source commit
- b3045439b7c0
- Source last updated
- Oct 21, 2026
- Last synchronized
- Oct 21, 2026
- Publication status
- published
Publication history
- Oct 21, 2026, 8:31 PM: new → published (ingestion) — Backed by an official breaking-change/migration guide.
AI_PROVIDER (for example to openai-compatible with a local Ollama or LM Studio endpoint) to enable grounded explanations. Everything else on this page works without an AI provider.