switch statement cleanup (#148382)
This PR is step 12 in the journey to solve issue #136139 and make the entire Flutter repo more readable. Most of it involves implementing switch expressions, and there's also a few other random things that I wanted to clean up a bit.
This commit is contained in:
@@ -353,16 +353,14 @@ class TestDefaultBinaryMessenger extends BinaryMessenger {
|
||||
final StreamController<Object?> controller = StreamController<Object?>();
|
||||
addTearDown(controller.close);
|
||||
|
||||
setMockMethodCallHandler(MethodChannel(channel.name, channel.codec), (MethodCall call) async {
|
||||
switch (call.method) {
|
||||
case 'listen':
|
||||
return handler.onListen(call.arguments, MockStreamHandlerEventSink(controller.sink));
|
||||
case 'cancel':
|
||||
return handler.onCancel(call.arguments);
|
||||
default:
|
||||
throw UnimplementedError('Method ${call.method} not implemented');
|
||||
}
|
||||
});
|
||||
setMockMethodCallHandler(
|
||||
MethodChannel(channel.name, channel.codec),
|
||||
(MethodCall call) async => switch (call.method) {
|
||||
'listen' => handler.onListen(call.arguments, MockStreamHandlerEventSink(controller.sink)),
|
||||
'cancel' => handler.onCancel(call.arguments),
|
||||
_ => throw UnimplementedError('Method ${call.method} not implemented'),
|
||||
},
|
||||
);
|
||||
|
||||
final StreamSubscription<Object?> sub = controller.stream.listen(
|
||||
(Object? e) => handlePlatformMessage(
|
||||
|
||||
Reference in New Issue
Block a user