feat: stop all servers in noti center (#901)

This commit is contained in:
lollipopkit🏳️‍⚧️
2025-09-06 14:04:53 +08:00
committed by GitHub
parent 0c7b72fb2c
commit 05a927753f
5 changed files with 124 additions and 80 deletions

View File

@@ -77,8 +77,10 @@ abstract final class MethodChans {
}
/// Register a handler for native -> Flutter callbacks.
/// Currently handles: `disconnectSession` with argument map {id: string}
static void registerHandler(Future<void> Function(String id) onDisconnect) {
/// Currently handles:
/// - `disconnectSession` with argument map {id: string}
/// - `stopAllConnections` with no arguments
static void registerHandler(Future<void> Function(String id) onDisconnect, [VoidCallback? onStopAll]) {
_channel.setMethodCallHandler((call) async {
switch (call.method) {
case 'disconnectSession':
@@ -88,6 +90,9 @@ abstract final class MethodChans {
await onDisconnect(id);
}
return;
case 'stopAllConnections':
onStopAll?.call();
return;
default:
return;
}