import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'custom_notification_platform_interface.dart'; /// An implementation of [CustomNotificationPlatform] that uses method channels. class MethodChannelCustomNotification extends CustomNotificationPlatform { /// The method channel used to interact with the native platform. @visibleForTesting final methodChannel = const MethodChannel('custom_notification'); MethodChannelCustomNotification() { methodChannel.setMethodCallHandler(_handleMethod); } final StreamController _recordActionStreamController = StreamController.broadcast(); Future _handleMethod(MethodCall call) async { debugPrint( 'MethodChannelCustomNotification _handleMethod ${call.method}'); switch (call.method) { case "recordAction": _recordAction(call.arguments); break; } } void _recordAction(dynamic action) { if (action is String) { _recordActionStreamController.add(action); } } @override Stream recordActionStream() { return _recordActionStreamController.stream; } @override Future showRecordNotification( int notificationId, bool isRecording, String timeDesc, {required String channelId, required String channelName}) async { return await methodChannel.invokeMethod("showRecordNotification", { "notificationId": notificationId, "isRecording": isRecording, "timeDesc": timeDesc, "channelId": channelId, "channelName": channelName, }); } }