| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 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<String> _recordActionStreamController =
- StreamController<String>.broadcast();
- Future<dynamic> _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<String> recordActionStream() {
- return _recordActionStreamController.stream;
- }
- @override
- Future<void> 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,
- });
- }
- }
|