a-mabe / a-mabe/background_hiit_timer

[Feature/Improvement] Migrate to audio_service from flutter_background_service

未关闭
#37 0 条评论 0 个 reaction 已指派 1 人 已被 @a-mabe 认领 在 GitHub 查看
enhancement
主要语言
Dart
星标
5
派生
3
PR 合并指标
30 天内没有已合并 PR

描述

# Overview

This issue describes the plan to replace `flutter_background_service` with `audio_service` as the background execution mechanism.

The current implementation uses [flutter_background_service](https://pub.dev/packages/flutter_background_service). It uses [SQFlite](https://pub.dev/packages/sqflite) for passing interval data, [SharedPreferences](https://pub.dev/packages/shared_preferences) for the pause flag, and service events (`service.invoke("stop");`). Migrating to audio_service will replace these with a single Dart stream.

## audio_service

[Tutorial](https://github.com/ryanheise/audio_service/wiki/Tutorial).

`audio_service` is built for long-running audio. It registers the app with the OS as a media player, which grants it a foreground service slot and lock-screen controls without any extra configuration. The BaseAudioHandler subclass runs in the same Dart isolate as the UI, so the interval list can be passed by reference in memory.

## Design

`HiitAudioHandler` - Extends the `BaseAudioHandler` class. Defines pause/play/skip, playSound, broadcasts state. This will replace flutter_background_service.

`Countdown` - Stateful widget, contains the streambuilder.

`CountdownController` - Public-facing controller that translates user calls into handler methods.

`IntervalType` - Unchanged.

`TimerState` - Unchanged.

贡献指南

打开贡献指南

调研方向

The issue describes replacing flutter_background_service with audio_service. Start by reading the linked audio_service tutorial. Examine the current service implementation and the proposed HiitAudioHandler class. The work involves understanding how to pass interval data via a Dart stream instead of SQFlite and SharedPreferences. Test the migration by running the app's background timer functionality.

由索引模型根据 Issue 内容生成。

评估

技术栈
dart, flutter
领域
audio-video-rtc, mobile
Issue 类型
重构
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
40/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。