@@ -8,9 +8,6 @@ import 'dart:ui' as ui;
88import  'package:fake_async/fake_async.dart' ;
99import  'package:flutter/services.dart' ;
1010
11- import  'mock_event_channel.dart' ;
12- import  'widget_tester.dart' ;
13- 
1411/// A function which takes the name of the method channel, it's handler, 
1512/// platform message and asynchronously returns an encoded response. 
1613typedef  AllMessagesHandler  =  Future <ByteData ?>?  Function (
@@ -200,9 +197,6 @@ class TestDefaultBinaryMessenger extends BinaryMessenger {
200197  /// 
201198  ///  * [setMockMethodCallHandler] , which wraps this method but decodes 
202199  ///    the messages using a [MethodCodec].  
203-   /// 
204-   ///  * [setMockStreamHandler] , which wraps [setMockMethodCallHandler]  to 
205-   ///    handle [EventChannel] messages.  
206200   void  setMockMessageHandler (String  channel, MessageHandler ?  handler, [ Object ?  identity ]) {
207201    if  (handler ==  null ) {
208202      _outboundHandlers.remove (channel);
@@ -243,9 +237,6 @@ class TestDefaultBinaryMessenger extends BinaryMessenger {
243237  /// 
244238  ///  * [setMockMethodCallHandler] , which is similar but decodes 
245239  ///    the messages using a [MethodCodec].  
246-   /// 
247-   ///  * [setMockStreamHandler] , which wraps [setMockMethodCallHandler]  to 
248-   ///    handle [EventChannel] messages.  
249240   void  setMockDecodedMessageHandler <T >(BasicMessageChannel <T > channel, Future <T > Function (T ?  message)?  handler) {
250241    if  (handler ==  null ) {
251242      setMockMessageHandler (channel.name, null );
@@ -311,81 +302,6 @@ class TestDefaultBinaryMessenger extends BinaryMessenger {
311302    }, handler);
312303  }
313304
314-   /// Set a handler for intercepting stream events sent to the 
315-   /// platform on the given channel. 
316-   /// 
317-   /// Intercepted method calls are not forwarded to the platform. 
318-   /// 
319-   /// The given handler will replace the currently registered 
320-   /// handler for that channel, if any. To stop intercepting messages 
321-   /// at all, pass null as the handler. 
322-   /// 
323-   /// Events are decoded using the codec of the channel. 
324-   /// 
325-   /// The handler's stream messages are used as a response, after encoding 
326-   /// them using the channel's codec. 
327-   /// 
328-   /// To send an error, pass the error information to the handler's event sink. 
329-   /// 
330-   /// {@macro flutter.flutter_test.TestDefaultBinaryMessenger.handlePlatformMessage.asyncHandlers} 
331-   /// 
332-   /// Registered handlers are cleared after each test. 
333-   /// 
334-   /// See also: 
335-   /// 
336-   ///  * [setMockMethodCallHandler] , which is the similar method for 
337-   ///    [MethodChannel].  
338-   /// 
339-   ///  * [setMockMessageHandler] , which is similar but provides raw 
340-   ///    access to the underlying bytes.  
341-   /// 
342-   ///  * [setMockDecodedMessageHandler] , which is similar but decodes 
343-   ///    the messages using a [MessageCodec].  
344-    void  setMockStreamHandler (EventChannel  channel, MockStreamHandler ?  handler) {
345-     if  (handler ==  null ) {
346-       setMockMessageHandler (channel.name, null );
347-       return ;
348-     }
349- 
350-     final  StreamController <Object ?> controller =  StreamController <Object ?>();
351-     addTearDown (controller.close);
352- 
353-     setMockMethodCallHandler (MethodChannel (channel.name, channel.codec), (MethodCall  call) async  {
354-       switch  (call.method) {
355-         case  'listen' : 
356-           return  handler.onListen (call.arguments, MockStreamHandlerEventSink (controller.sink));
357-         case  'cancel' : 
358-           return  handler.onCancel (call.arguments);
359-         default : 
360-           throw  UnimplementedError ('Method ${call .method } not implemented' );
361-       }
362-     });
363- 
364-     final  StreamSubscription <Object ?> sub =  controller.stream.listen (
365-       (Object ?  e) =>  channel.binaryMessenger.handlePlatformMessage (
366-         channel.name,
367-         channel.codec.encodeSuccessEnvelope (e),
368-         null ,
369-       ),
370-     );
371-     addTearDown (sub.cancel);
372-     sub.onError ((Object ?  e) {
373-       if  (e is !  PlatformException ) {
374-         throw  ArgumentError ('Stream error must be a PlatformException' );
375-       }
376-       channel.binaryMessenger.handlePlatformMessage (
377-         channel.name,
378-         channel.codec.encodeErrorEnvelope (
379-           code:  e.code,
380-           message:  e.message,
381-           details:  e.details,
382-         ),
383-         null ,
384-       );
385-     });
386-     sub.onDone (() =>  channel.binaryMessenger.handlePlatformMessage (channel.name, null , null ));
387-   }
388- 
389305  /// Returns true if the `handler`  argument matches the `handler`  
390306  /// previously passed to [setMockMessageHandler] , 
391307  /// [setMockDecodedMessageHandler] , or [setMockMethodCallHandler] . 
0 commit comments