1// Copyright 2014 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5/// @docImport 'dart:typed_data';
6///
7/// @docImport 'package:flutter/semantics.dart';
8/// @docImport 'package:flutter/widgets.dart';
9///
10/// @docImport 'binding.dart';
11/// @docImport 'clipboard.dart';
12/// @docImport 'haptic_feedback.dart';
13/// @docImport 'platform_views.dart';
14/// @docImport 'raw_keyboard.dart';
15/// @docImport 'raw_keyboard_android.dart';
16/// @docImport 'raw_keyboard_fuchsia.dart';
17/// @docImport 'scribe.dart';
18/// @docImport 'system_chrome.dart';
19/// @docImport 'system_navigator.dart';
20/// @docImport 'system_sound.dart';
21/// @docImport 'text_input.dart';
22library;
23
24import 'dart:ui';
25
26import 'message_codecs.dart';
27import 'platform_channel.dart';
28
29export 'platform_channel.dart' show BasicMessageChannel, MethodChannel;
30
31/// Platform channels used by the Flutter system.
32abstract final class SystemChannels {
33 /// A JSON [MethodChannel] for navigation.
34 ///
35 /// The following incoming methods are defined for this channel (registered
36 /// using [MethodChannel.setMethodCallHandler]):
37 ///
38 /// * `popRoute`, which is called when the system wants the current route to
39 /// be removed (e.g. if the user hits a system-level back button).
40 ///
41 /// * `pushRoute`, which is called with a single string argument when the
42 /// operating system instructs the application to open a particular page.
43 ///
44 /// * `pushRouteInformation`, which is called with a map, which contains a
45 /// location string and a state object, when the operating system instructs
46 /// the application to open a particular page. These parameters are stored
47 /// under the key `location` and `state` in the map.
48 ///
49 /// The following methods are used for the opposite direction data flow. The
50 /// framework notifies the engine about the route changes.
51 ///
52 /// * `selectSingleEntryHistory`, which enables a single-entry history mode.
53 ///
54 /// * `selectMultiEntryHistory`, which enables a multiple-entry history mode.
55 ///
56 /// * `routeInformationUpdated`, which is called when the application
57 /// navigates to a new location, and which takes two arguments, `location`
58 /// (a URL) and `state` (an object).
59 ///
60 /// * `routeUpdated`, a deprecated API which can be called in the same
61 /// situations as `routeInformationUpdated` but whose arguments are
62 /// `routeName` (a URL) and `previousRouteName` (which is ignored).
63 ///
64 /// These APIs are exposed by the [SystemNavigator] class.
65 ///
66 /// See also:
67 ///
68 /// * [WidgetsBindingObserver.didPopRoute] and
69 /// [WidgetsBindingObserver.didPushRoute], which expose this channel's
70 /// methods.
71 /// * [Navigator] which manages transitions from one page to another.
72 /// [Navigator.push], [Navigator.pushReplacement], [Navigator.pop] and
73 /// [Navigator.replace], utilize this channel's methods to send route
74 /// change information from framework to engine.
75 static const MethodChannel navigation = OptionalMethodChannel(
76 'flutter/navigation',
77 JSONMethodCodec(),
78 );
79
80 /// A [MethodChannel] for handling predictive back gestures.
81 ///
82 /// Currently, this feature is only available on Android U and above.
83 ///
84 /// No outgoing methods are defined for this channel (invoked using
85 /// [OptionalMethodChannel.invokeMethod]).
86 ///
87 /// The following incoming methods are defined for this channel (registered
88 /// using [MethodChannel.setMethodCallHandler]):
89 ///
90 /// * `startBackGesture`: The user has started a predictive back gesture.
91 /// * `updateBackGestureProgress`: The user has continued dragging the
92 /// predictive back gesture.
93 /// * `commitBackGesture`: The user has finished a predictive back gesture,
94 /// indicating that the current route should be popped.
95 /// * `cancelBackGesture`: The user has canceled a predictive back gesture,
96 /// indicating that no navigation should occur.
97 static const MethodChannel backGesture = OptionalMethodChannel('flutter/backgesture');
98
99 /// A JSON [MethodChannel] for invoking miscellaneous platform methods.
100 ///
101 /// The following outgoing methods are defined for this channel (invoked using
102 /// [OptionalMethodChannel.invokeMethod]):
103 ///
104 /// * `Clipboard.setData`: Places the data from the `text` entry of the
105 /// argument, which must be a [Map], onto the system clipboard. See
106 /// [Clipboard.setData].
107 ///
108 /// * `Clipboard.getData`: Returns the data that has the format specified in
109 /// the argument, a [String], from the system clipboard. The only format
110 /// currently supported is `text/plain` ([Clipboard.kTextPlain]). The
111 /// result is a [Map] with a single key, `text`. See [Clipboard.getData].
112 ///
113 /// * `HapticFeedback.vibrate`: Triggers a system-default haptic response.
114 /// See [HapticFeedback.vibrate].
115 ///
116 /// * `SystemSound.play`: Triggers a system audio effect. The argument must
117 /// be a [String] describing the desired effect; currently only `click` is
118 /// supported. See [SystemSound.play].
119 ///
120 /// * `SystemChrome.setPreferredOrientations`: Informs the operating system
121 /// of the desired orientation of the display. The argument is a [List] of
122 /// values which are string representations of values of the
123 /// [DeviceOrientation] enum. See [SystemChrome.setPreferredOrientations].
124 ///
125 /// * `SystemChrome.setApplicationSwitcherDescription`: Informs the operating
126 /// system of the desired label and color to be used to describe the
127 /// application in any system-level application lists (e.g. application
128 /// switchers). The argument is a [Map] with two keys, `label` giving a
129 /// [String] description, and `primaryColor` giving a 32 bit integer value
130 /// (the lower eight bits being the blue channel, the next eight bits being
131 /// the green channel, the next eight bits being the red channel, and the
132 /// high eight bits being set, as from [Color.value] for an opaque color).
133 /// The `primaryColor` can also be zero to indicate that the system default
134 /// should be used. See [SystemChrome.setApplicationSwitcherDescription].
135 ///
136 /// * `SystemChrome.setEnabledSystemUIOverlays`: Specifies the set of system
137 /// overlays to have visible when the application is running. The argument
138 /// is a [List] of values which are string representations of values of the
139 /// [SystemUiOverlay] enum. See [SystemChrome.setEnabledSystemUIMode].
140 /// [SystemUiOverlay]s can only be configured individually when using
141 /// [SystemUiMode.manual].
142 ///
143 /// * `SystemChrome.setEnabledSystemUIMode`: Specifies the [SystemUiMode] for
144 /// the application. The optional `overlays` argument is a [List] of values
145 /// which are string representations of values of the [SystemUiOverlay]
146 /// enum when using [SystemUiMode.manual]. See
147 /// [SystemChrome.setEnabledSystemUIMode].
148 ///
149 /// * `SystemChrome.setSystemUIOverlayStyle`: Specifies whether system
150 /// overlays (e.g. the status bar on Android or iOS) should be `light` or
151 /// `dark`. The argument is one of those two strings. See
152 /// [SystemChrome.setSystemUIOverlayStyle].
153 ///
154 /// * `SystemNavigator.pop`: Tells the operating system to close the
155 /// application, or the closest equivalent. See [SystemNavigator.pop].
156 ///
157 /// * `System.exitApplication`: Tells the engine to send a request back to
158 /// the application to request an application exit (using
159 /// `System.requestAppExit` below), and if it is not canceled, to terminate
160 /// the application using the platform UI toolkit's termination API.
161 ///
162 /// The following incoming methods are defined for this channel (registered
163 /// using [MethodChannel.setMethodCallHandler]):
164 ///
165 /// * `SystemChrome.systemUIChange`: The user has changed the visibility of
166 /// the system overlays. This is relevant when using [SystemUiMode]s
167 /// through [SystemChrome.setEnabledSystemUIMode]. See
168 /// [SystemChrome.setSystemUIChangeCallback] to respond to this change in
169 /// application state.
170 ///
171 /// * `System.requestAppExit`: The application has requested that it be
172 /// terminated. See [ServicesBinding.exitApplication].
173 ///
174 /// * `System.initializationComplete`: Indicate to the engine the
175 /// initialization of a binding that may, among other tasks, register a
176 /// handler for application exit attempts.
177 ///
178 /// Calls to methods that are not implemented on the shell side are ignored
179 /// (so it is safe to call methods when the relevant plugin might be missing).
180 static const MethodChannel platform = OptionalMethodChannel(
181 'flutter/platform',
182 JSONMethodCodec(),
183 );
184
185 /// A [MethodChannel] for handling text processing actions.
186 ///
187 /// This channel exposes the text processing feature for supported platforms.
188 /// Currently supported on Android only.
189 static const MethodChannel processText = OptionalMethodChannel('flutter/processtext');
190
191 /// A JSON [MethodChannel] for handling text input.
192 ///
193 /// This channel exposes a system text input control for interacting with IMEs
194 /// (input method editors, for example on-screen keyboards). There is one
195 /// control, and at any time it can have one active transaction. Transactions
196 /// are represented by an integer. New Transactions are started by
197 /// `TextInput.setClient`. Messages that are sent are assumed to be for the
198 /// current transaction (the last "client" set by `TextInput.setClient`).
199 /// Messages received from the shell side specify the transaction to which
200 /// they apply, so that stale messages referencing past transactions can be
201 /// ignored.
202 ///
203 /// In debug builds, messages sent with a client ID of -1 are always accepted.
204 /// This allows tests to smuggle messages without having to mock the engine's
205 /// text handling (for example, allowing the engine to still handle the text
206 /// input messages in an integration test).
207 ///
208 /// The methods described below are wrapped in a more convenient form by the
209 /// [TextInput] and [TextInputConnection] class.
210 ///
211 /// The following outgoing methods are defined for this channel (invoked using
212 /// [OptionalMethodChannel.invokeMethod]):
213 ///
214 /// * `TextInput.setClient`: Establishes a new transaction. The arguments is
215 /// a [List] whose first value is an integer representing a previously
216 /// unused transaction identifier, and the second is a [String] with a
217 /// JSON-encoded object with five keys, as obtained from
218 /// [TextInputConfiguration.toJson]. This method must be invoked before any
219 /// others (except `TextInput.hide`). See [TextInput.attach].
220 ///
221 /// * `TextInput.show`: Show the keyboard. See [TextInputConnection.show].
222 ///
223 /// * `TextInput.setEditingState`: Update the value in the text editing
224 /// control. The argument is a [String] with a JSON-encoded object with
225 /// seven keys, as obtained from [TextEditingValue.toJSON]. See
226 /// [TextInputConnection.setEditingState].
227 ///
228 /// * `TextInput.clearClient`: End the current transaction. The next method
229 /// called must be `TextInput.setClient` (or `TextInput.hide`). See
230 /// [TextInputConnection.close].
231 ///
232 /// * `TextInput.hide`: Hide the keyboard. Unlike the other methods, this can
233 /// be called at any time. See [TextInputConnection.close].
234 ///
235 /// The following incoming methods are defined for this channel (registered
236 /// using [MethodChannel.setMethodCallHandler]). In each case, the first argument
237 /// is a transaction identifier. Calls for stale transactions should be ignored.
238 ///
239 /// * `TextInputClient.updateEditingState`: The user has changed the contents
240 /// of the text control. The second argument is an object with seven keys,
241 /// in the form expected by [TextEditingValue.fromJSON].
242 ///
243 /// * `TextInputClient.updateEditingStateWithTag`: One or more text controls
244 /// were autofilled by the platform's autofill service. The first argument
245 /// (the client ID) is ignored, the second argument is a map of tags to
246 /// objects in the form expected by [TextEditingValue.fromJSON]. See
247 /// [AutofillScope.getAutofillClient] for details on the interpretation of
248 /// the tag.
249 ///
250 /// * `TextInputClient.performAction`: The user has triggered an action. The
251 /// second argument is a [String] consisting of the stringification of one
252 /// of the values of the [TextInputAction] enum.
253 ///
254 /// * `TextInputClient.requestExistingInputState`: The embedding may have
255 /// lost its internal state about the current editing client, if there is
256 /// one. The framework should call `TextInput.setClient` and
257 /// `TextInput.setEditingState` again with its most recent information. If
258 /// there is no existing state on the framework side, the call should
259 /// fizzle. (This call is made without a client ID; indeed, without any
260 /// arguments at all.)
261 ///
262 /// * `TextInputClient.onConnectionClosed`: The text input connection closed
263 /// on the platform side. For example the application is moved to
264 /// background or used closed the virtual keyboard. This method informs
265 /// [TextInputClient] to clear connection and finalize editing.
266 /// `TextInput.clearClient` and `TextInput.hide` is not called after
267 /// clearing the connection since on the platform side the connection is
268 /// already finalized.
269 ///
270 /// Calls to methods that are not implemented on the shell side are ignored
271 /// (so it is safe to call methods when the relevant plugin might be missing).
272 static const MethodChannel textInput = OptionalMethodChannel(
273 'flutter/textinput',
274 JSONMethodCodec(),
275 );
276
277 /// A [MethodChannel] for handling Android Scribe stylus handwriting input.
278 ///
279 /// Android's Scribe feature allows writing directly on top of a text input
280 /// using a stylus.
281 ///
282 /// The following methods are defined for this channel:
283 ///
284 /// * `Scribe.startStylusHandwriting`: Indicates that stylus input has been
285 /// detected and Android should start handwriting input.
286 /// * `Scribe.isStylusHandwritingAvailable`: Returns a boolean representing
287 /// whether or not the device currently supports accepting stylus handwriting
288 /// input. Throws if the device's API level is not sufficient.
289 /// * `Scribe.isFeatureAvailable`: Returns a boolean representing whether or
290 /// not the device currently supports accepting stylus handwriting input.
291 /// Returns false and does not throw if the device's API level is not
292 /// sufficient.
293 ///
294 /// See also:
295 ///
296 /// * [Scribe], which uese this channel.
297 /// * [ScribbleClient], which implements the iOS version of this feature,
298 /// [Scribble](https://support.apple.com/guide/ipad/enter-text-with-scribble-ipad355ab2a7/ipados).
299 /// * <https://developer.android.com/develop/ui/views/touch-and-input/stylus-input/stylus-input-in-text-fields>,
300 /// which is the Android documentation explaining the Scribe feature.
301 static const MethodChannel scribe = OptionalMethodChannel('flutter/scribe', JSONMethodCodec());
302
303 /// A [MethodChannel] for handling spell check for text input.
304 ///
305 /// This channel exposes the spell check framework for supported platforms.
306 /// Currently supported on Android and iOS only.
307 ///
308 /// Spell check requests are initiated by `SpellCheck.initiateSpellCheck`.
309 /// These requests may either be completed or canceled. If the request is
310 /// completed, the shell side will respond with the results of the request.
311 /// Otherwise, the shell side will respond with null.
312 ///
313 /// The following outgoing methods are defined for this channel (invoked by
314 /// [OptionalMethodChannel.invokeMethod]):
315 ///
316 /// * `SpellCheck.initiateSpellCheck`: Sends request for specified text to be
317 /// spell checked and returns the result, either a [List<SuggestionSpan>]
318 /// representing the spell check results of the text or null if the request
319 /// was canceled. The arguments are the [String] to be spell checked
320 /// and the [Locale] for the text to be spell checked with.
321 static const MethodChannel spellCheck = OptionalMethodChannel('flutter/spellcheck');
322
323 /// A JSON [MethodChannel] for handling undo events.
324 static const MethodChannel undoManager = OptionalMethodChannel(
325 'flutter/undomanager',
326 JSONMethodCodec(),
327 );
328
329 /// A JSON [BasicMessageChannel] for keyboard events.
330 ///
331 /// Each incoming message received on this channel (registered using
332 /// [BasicMessageChannel.setMessageHandler]) consists of a [Map] with
333 /// platform-specific data, plus a `type` field which is either `keydown`, or
334 /// `keyup`.
335 ///
336 /// On Android, the available fields are those described by
337 /// [RawKeyEventDataAndroid]'s properties.
338 ///
339 /// On Fuchsia, the available fields are those described by
340 /// [RawKeyEventDataFuchsia]'s properties.
341 ///
342 /// No messages are sent on other platforms currently.
343 ///
344 /// See also:
345 ///
346 /// * [RawKeyboard], which uses this channel to expose key data.
347 /// * [RawKeyEvent.fromMessage], which can decode this data into the [RawKeyEvent]
348 /// subclasses mentioned above.
349 static const BasicMessageChannel<Object?> keyEvent = BasicMessageChannel<Object?>(
350 'flutter/keyevent',
351 JSONMessageCodec(),
352 );
353
354 /// A string [BasicMessageChannel] for lifecycle events.
355 ///
356 /// Valid messages are string representations of the values of the
357 /// [AppLifecycleState] enumeration. A handler can be registered using
358 /// [BasicMessageChannel.setMessageHandler].
359 ///
360 /// See also:
361 ///
362 /// * [WidgetsBindingObserver.didChangeAppLifecycleState], which triggers
363 /// whenever a message is received on this channel.
364 static const BasicMessageChannel<String?> lifecycle = BasicMessageChannel<String?>(
365 'flutter/lifecycle',
366 StringCodec(),
367 );
368
369 /// A JSON [BasicMessageChannel] for system events.
370 ///
371 /// Events are exposed as [Map]s with string keys. The `type` key specifies
372 /// the type of the event; the currently supported system event types are
373 /// those listed below. A handler can be registered using
374 /// [BasicMessageChannel.setMessageHandler].
375 ///
376 /// * `memoryPressure`: Indicates that the operating system would like
377 /// applications to release caches to free up more memory. See
378 /// [WidgetsBindingObserver.didHaveMemoryPressure], which triggers whenever
379 /// a message is received on this channel.
380 static const BasicMessageChannel<Object?> system = BasicMessageChannel<Object?>(
381 'flutter/system',
382 JSONMessageCodec(),
383 );
384
385 /// A [BasicMessageChannel] for accessibility events.
386 ///
387 /// See also:
388 ///
389 /// * [SemanticsEvent] and its subclasses for a list of valid accessibility
390 /// events that can be sent over this channel.
391 /// * [SemanticsNode.sendEvent], which uses this channel to dispatch events.
392 static const BasicMessageChannel<Object?> accessibility = BasicMessageChannel<Object?>(
393 'flutter/accessibility',
394 StandardMessageCodec(),
395 );
396
397 /// A [MethodChannel] for controlling platform views.
398 ///
399 /// See also:
400 ///
401 /// * [PlatformViewsService] for the available operations on this channel.
402 static const MethodChannel platform_views = MethodChannel('flutter/platform_views');
403
404 /// A [MethodChannel] for controlling platform views.
405 ///
406 /// See also:
407 ///
408 /// * [PlatformViewsService] for the available operations on this channel.
409 static const MethodChannel platform_views_2 = MethodChannel('flutter/platform_views_2');
410
411 /// A [MethodChannel] for configuring the Skia graphics library.
412 ///
413 /// The following outgoing methods are defined for this channel (invoked using
414 /// [OptionalMethodChannel.invokeMethod]):
415 ///
416 /// * `Skia.setResourceCacheMaxBytes`: Set the maximum number of bytes that
417 /// can be held in the GPU resource cache.
418 static const MethodChannel skia = MethodChannel('flutter/skia', JSONMethodCodec());
419
420 /// A [MethodChannel] for configuring mouse cursors.
421 ///
422 /// All outgoing methods defined for this channel uses a `Map<String, Object?>`
423 /// to contain multiple parameters, including the following methods (invoked
424 /// using [OptionalMethodChannel.invokeMethod]):
425 ///
426 /// * `activateSystemCursor`: Request to set the cursor of a pointer
427 /// device to a system cursor. The parameters are
428 /// integer `device`, and string `kind`.
429 static const MethodChannel mouseCursor = OptionalMethodChannel('flutter/mousecursor');
430
431 /// A [MethodChannel] for synchronizing restoration data with the engine.
432 ///
433 /// The following outgoing methods are defined for this channel (invoked using
434 /// [OptionalMethodChannel.invokeMethod]):
435 ///
436 /// * `get`: Retrieves the current restoration information (e.g. provided by
437 /// the operating system) from the engine. The method returns a map
438 /// containing an `enabled` boolean to indicate whether collecting
439 /// restoration data is supported by the embedder. If `enabled` is true,
440 /// the map may also contain restoration data stored under the `data` key
441 /// from which the state of the framework may be restored. The restoration
442 /// data is encoded as [Uint8List].
443 /// * `put`: Sends the current restoration data to the engine. Takes the
444 /// restoration data encoded as [Uint8List] as argument.
445 ///
446 /// The following incoming methods are defined for this channel (registered
447 /// using [MethodChannel.setMethodCallHandler]).
448 ///
449 /// * `push`: Called by the engine to send newly provided restoration
450 /// information to the framework. The argument given to this method has
451 /// the same format as the object that the `get` method returns.
452 ///
453 /// See also:
454 ///
455 /// * [RestorationManager], which uses this channel and also describes how
456 /// restoration data is used in Flutter.
457 static const MethodChannel restoration = OptionalMethodChannel('flutter/restoration');
458
459 /// A [MethodChannel] for installing and managing deferred components.
460 ///
461 /// The following outgoing methods are defined for this channel (invoked using
462 /// [OptionalMethodChannel.invokeMethod]):
463 ///
464 /// * `installDeferredComponent`: Requests that a deferred component identified by
465 /// the provided loadingUnitId or componentName be downloaded and installed.
466 /// Providing a loadingUnitId with null componentName will install a component that
467 /// includes the desired loading unit. If a componentName is provided, then the
468 /// deferred component with the componentName will be installed. This method
469 /// returns a future that will not be completed until the feature is fully installed
470 /// and ready to use. When an error occurs, the future will complete an error.
471 /// Calling `loadLibrary()` on a deferred imported library is equivalent to calling
472 /// this method with a loadingUnitId and null componentName.
473 /// * `uninstallDeferredComponent`: Requests that a deferred component identified by
474 /// the provided loadingUnitId or componentName be uninstalled. Since
475 /// uninstallation typically requires significant disk i/o, this method only
476 /// signals the intent to uninstall. Actual uninstallation (eg, removal of
477 /// assets and files) may occur at a later time. However, once uninstallation
478 /// is requested, the deferred component should not be used anymore until
479 /// `installDeferredComponent` or `loadLibrary` is called again.
480 static const MethodChannel deferredComponent = OptionalMethodChannel('flutter/deferredcomponent');
481
482 /// A JSON [MethodChannel] for localization.
483 ///
484 /// The following outgoing methods are defined for this channel (invoked using
485 /// [OptionalMethodChannel.invokeMethod]):
486 ///
487 /// * `Localization.getStringResource`: Obtains the native string resource
488 /// for a specific locale. The argument is a [Map] with two keys, `key`
489 /// giving a [String] which the resource is defined with, and an optional
490 /// `locale` which is a [String] containing the BCP47 locale identifier of
491 /// the locale requested. See [Locale.toLanguageTag]. When `locale` is not
492 /// specified, the current system locale is used instead.
493 static const MethodChannel localization = OptionalMethodChannel(
494 'flutter/localization',
495 JSONMethodCodec(),
496 );
497
498 /// A [MethodChannel] for platform menu specification and control.
499 ///
500 /// The following outgoing method is defined for this channel (invoked using
501 /// [OptionalMethodChannel.invokeMethod]):
502 ///
503 /// * `Menu.setMenus`: sends the configuration of the platform menu, including
504 /// labels, enable/disable information, and unique integer identifiers for
505 /// each menu item. The configuration is sent as a `Map<String, Object?>`
506 /// encoding the list of top level menu items in window "0", which each
507 /// have a hierarchy of `Map<String, Object?>` containing the required
508 /// data, sent via a [StandardMessageCodec]. It is typically generated from
509 /// a list of [PlatformMenuItem]s, and ends up looking like this example:
510 ///
511 /// ```dart
512 /// Map<String, Object?> menu = <String, Object?>{
513 /// '0': <Map<String, Object?>>[
514 /// <String, Object?>{
515 /// 'id': 1,
516 /// 'label': 'First Menu Label',
517 /// 'enabled': true,
518 /// 'children': <Map<String, Object?>>[
519 /// <String, Object?>{
520 /// 'id': 2,
521 /// 'label': 'Sub Menu Label',
522 /// 'enabled': true,
523 /// },
524 /// ],
525 /// },
526 /// ],
527 /// };
528 /// ```
529 ///
530 /// The following incoming methods are defined for this channel (registered
531 /// using [MethodChannel.setMethodCallHandler]).
532 ///
533 /// * `Menu.selectedCallback`: Called when a menu item is selected, along
534 /// with the unique ID of the menu item selected.
535 ///
536 /// * `Menu.opened`: Called when a submenu is opened, along with the unique
537 /// ID of the submenu.
538 ///
539 /// * `Menu.closed`: Called when a submenu is closed, along with the unique
540 /// ID of the submenu.
541 ///
542 /// See also:
543 ///
544 /// * [DefaultPlatformMenuDelegate], which uses this channel.
545 static const MethodChannel menu = OptionalMethodChannel('flutter/menu');
546
547 /// A [MethodChannel] for configuring the browser's context menu on web.
548 ///
549 /// The following outgoing methods are defined for this channel (invoked using
550 /// [OptionalMethodChannel.invokeMethod]):
551 ///
552 /// * `enableContextMenu`: enables the browser's context menu. When a Flutter
553 /// app starts, the browser's context menu is already enabled.
554 /// * `disableContextMenu`: disables the browser's context menu.
555 static const MethodChannel contextMenu = OptionalMethodChannel(
556 'flutter/contextmenu',
557 JSONMethodCodec(),
558 );
559
560 /// A [MethodChannel] for retrieving keyboard pressed keys from the engine.
561 ///
562 /// The following outgoing methods are defined for this channel (invoked using
563 /// [OptionalMethodChannel.invokeMethod]):
564 ///
565 /// * `getKeyboardState`: Obtains keyboard pressed keys from the engine.
566 /// The keyboard state is sent as a `Map<int, int>?` where each entry
567 /// represents a pressed keyboard key. The entry key is the physical
568 /// key ID and the entry value is the logical key ID.
569 ///
570 /// Both the framework and the engine maintain a state of the current
571 /// pressed keys. There are edge cases, related to startup and restart,
572 /// where the framework needs to resynchronize its keyboard state.
573 ///
574 /// See also:
575 ///
576 /// * [HardwareKeyboard.syncKeyboardState], which uses this channel to synchronize
577 /// the `HardwareKeyboard` pressed state.
578 static const MethodChannel keyboard = OptionalMethodChannel('flutter/keyboard');
579}
580

Provided by KDAB

Privacy Policy
Learn more about Flutter for embedded and desktop on industrialflutter.com