Flutter 如何滑动 audio_service 包的通知?
Flutter how to swipe audio_service package's notification?
目前,关闭通知的唯一方法是按停止按钮。但我想知道如何用可滑动的“东西”来包装通知小部件。你能告诉我任何适用于此的包或我必须从 audio_service 包中打包东西的代码吗?
audio_service 软件包发布者是 - ryanheise.com
作为一个有用的提示,搜索 audio_service 的整个文档以找到某个问题的答案的最简单方法是导航到 audio_service.dart
文件(包含整个插件),然后搜索“滑动”一词。您将在 AudioServiceConfig
:
上找到此选项
/// Whether the Android service should switch to a lower priority state when
/// playback is paused allowing the user to swipe away the notification. Note
/// that while in this lower priority state, the operating system will also be
/// able to kill your service at any time to reclaim resources.
final bool androidStopForegroundOnPause;
然后在AudioHandler
里面:
/// Handle the notification being swiped away (Android).
Future<void> onNotificationDeleted();
(您可能会发现这比阅读在线 HTML 文档更容易搜索。)
上面的意思是你需要将androidStopForegroundOnPause: true
作为参数传递给AudioServiceConfig
,然后如果你想处理除默认(停止服务)之外的任何特殊行为,当用户滑动通知,您可以选择在自己的音频处理程序中覆盖 onNotificationDeleted
。 iOS.
没有等价物
请注意,在播放音频时无法滑动 Android 通知,但上述选项可让您在暂停状态下滑动通知。
目前,关闭通知的唯一方法是按停止按钮。但我想知道如何用可滑动的“东西”来包装通知小部件。你能告诉我任何适用于此的包或我必须从 audio_service 包中打包东西的代码吗?
audio_service 软件包发布者是 - ryanheise.com
作为一个有用的提示,搜索 audio_service 的整个文档以找到某个问题的答案的最简单方法是导航到 audio_service.dart
文件(包含整个插件),然后搜索“滑动”一词。您将在 AudioServiceConfig
:
/// Whether the Android service should switch to a lower priority state when
/// playback is paused allowing the user to swipe away the notification. Note
/// that while in this lower priority state, the operating system will also be
/// able to kill your service at any time to reclaim resources.
final bool androidStopForegroundOnPause;
然后在AudioHandler
里面:
/// Handle the notification being swiped away (Android).
Future<void> onNotificationDeleted();
(您可能会发现这比阅读在线 HTML 文档更容易搜索。)
上面的意思是你需要将androidStopForegroundOnPause: true
作为参数传递给AudioServiceConfig
,然后如果你想处理除默认(停止服务)之外的任何特殊行为,当用户滑动通知,您可以选择在自己的音频处理程序中覆盖 onNotificationDeleted
。 iOS.
请注意,在播放音频时无法滑动 Android 通知,但上述选项可让您在暂停状态下滑动通知。