Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 8bd4dcd

Browse files
committed
Add deprecations to PlatformMessage stuff
1 parent 51928f2 commit 8bd4dcd

File tree

3 files changed

+38
-6
lines changed

3 files changed

+38
-6
lines changed

lib/ui/channel_buffers.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66
// KEEP THIS SYNCHRONIZED WITH ../web_ui/lib/channel_buffers.dart
77
part of dart.ui;
88

9+
/// Deprecated. Migrate to [ChannelCallback] isntead.
10+
///
911
/// Signature for [ChannelBuffers.drain]'s `callback` argument.
1012
///
1113
/// The first argument is the data sent by the plugin.
1214
///
1315
/// The second argument is a closure that, when called, will send messages
1416
/// back to the plugin.
15-
// TODO(ianh): deprecate this once the framework is migrated to [ChannelCallback].
17+
@Deprecated(
18+
'Migrate to ChannelCallback instead. '
19+
'This feature was deprecated after v3.11.0-20.0.pre.',
20+
)
1621
typedef DrainChannelCallback = Future<void> Function(ByteData? data, PlatformMessageResponseCallback callback);
1722

1823
/// Signature for [ChannelBuffers.setListener]'s `callback` argument.
@@ -377,14 +382,19 @@ class ChannelBuffers {
377382
}
378383
}
379384

385+
/// Deprecated. Migrate to [setListener] instead.
386+
///
380387
/// Remove and process all stored messages for a given channel.
381388
///
382389
/// This should be called once a channel is prepared to handle messages
383390
/// (i.e. when a message handler is set up in the framework).
384391
///
385392
/// The messages are processed by calling the given `callback`. Each message
386393
/// is processed in its own microtask.
387-
// TODO(ianh): deprecate once framework uses [setListener].
394+
@Deprecated(
395+
'Migrate to setListener instead. '
396+
'This feature was deprecated after v3.11.0-20.0.pre.',
397+
)
388398
Future<void> drain(String name, DrainChannelCallback callback) async {
389399
final _Channel? channel = _channels[name];
390400
while (channel != null && !channel._queue.isEmpty) {

lib/ui/platform_dispatcher.dart

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ typedef SemanticsActionEventCallback = void Function(SemanticsActionEvent action
4545
/// [PlatformDispatcher.onPlatformMessage].
4646
typedef PlatformMessageResponseCallback = void Function(ByteData? data);
4747

48+
/// Deprecated. Migrate to [ChannelBuffers.setListener] instead.
49+
///
4850
/// Signature for [PlatformDispatcher.onPlatformMessage].
49-
// TODO(ianh): deprecate once framework uses [ChannelBuffers.setListener].
51+
@Deprecated(
52+
'Migrate to ChannelBuffers.setListener instead. '
53+
'This feature was deprecated after v3.11.0-20.0.pre.',
54+
)
5055
typedef PlatformMessageCallback = void Function(String name, ByteData? data, PlatformMessageResponseCallback? callback);
5156

5257
// Signature for _setNeedsReportTimings.
@@ -655,6 +660,8 @@ class PlatformDispatcher {
655660
@Native<Void Function(Int64)>(symbol: 'PlatformConfigurationNativeApi::RegisterBackgroundIsolate')
656661
external static void __registerBackgroundIsolate(int rootIsolateId);
657662

663+
/// Deprecated. Migrate to [ChannelBuffers.setListener] instead.
664+
///
658665
/// Called whenever this platform dispatcher receives a message from a
659666
/// platform-specific plugin.
660667
///
@@ -668,11 +675,17 @@ class PlatformDispatcher {
668675
///
669676
/// The framework invokes this callback in the same zone in which the callback
670677
/// was set.
671-
// TODO(ianh): Deprecate onPlatformMessage once the framework is moved over
672-
// to using channel buffers exclusively.
678+
@Deprecated(
679+
'Migrate to ChannelBuffers.setListener instead. '
680+
'This feature was deprecated after v3.11.0-20.0.pre.',
681+
)
673682
PlatformMessageCallback? get onPlatformMessage => _onPlatformMessage;
674683
PlatformMessageCallback? _onPlatformMessage;
675684
Zone _onPlatformMessageZone = Zone.root;
685+
@Deprecated(
686+
'Migrate to ChannelBuffers.setListener instead. '
687+
'This feature was deprecated after v3.11.0-20.0.pre.',
688+
)
676689
set onPlatformMessage(PlatformMessageCallback? callback) {
677690
_onPlatformMessage = callback;
678691
_onPlatformMessageZone = Zone.current;

lib/ui/window.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,8 @@ class SingletonFlutterWindow extends FlutterView {
802802
platformDispatcher.sendPlatformMessage(name, data, callback);
803803
}
804804

805+
/// Deprecated. Migrate to [ChannelBuffers.setListener] instead.
806+
///
805807
/// Called whenever this window receives a message from a platform-specific
806808
/// plugin.
807809
///
@@ -817,8 +819,15 @@ class SingletonFlutterWindow extends FlutterView {
817819
///
818820
/// The framework invokes this callback in the same zone in which the
819821
/// callback was set.
820-
// TODO(ianh): deprecate once framework uses [ChannelBuffers.setListener].
822+
@Deprecated(
823+
'Migrate to ChannelBuffers.setListener instead. '
824+
'This feature was deprecated after v3.11.0-20.0.pre.',
825+
)
821826
PlatformMessageCallback? get onPlatformMessage => platformDispatcher.onPlatformMessage;
827+
@Deprecated(
828+
'Migrate to ChannelBuffers.setListener instead. '
829+
'This feature was deprecated after v3.11.0-20.0.pre.',
830+
)
822831
set onPlatformMessage(PlatformMessageCallback? callback) {
823832
platformDispatcher.onPlatformMessage = callback;
824833
}

0 commit comments

Comments
 (0)