所有数据库表,提供相应的provider、桥接等方法

This commit is contained in:
Happi (哈比)
2026-03-10 12:09:45 +08:00
parent 084b7bbd23
commit 8130bf63fa
79 changed files with 3465 additions and 2730 deletions

View File

@@ -0,0 +1,34 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:im_app/app/di/db_provider.dart';
import 'package:im_app/data/repositories/sound_repository_impl.dart';
import 'package:im_app/domain/entities/sound.dart';
import 'package:im_app/domain/repositories/sound_repository.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'sound_provider.g.dart';
// ── Repository ────────────────────────────────────────────────────────────────
final soundRepositoryProvider = Provider<SoundRepository>((ref) {
return SoundRepositoryImpl(ref.watch(storageSdkProvider));
});
// ── Streams ───────────────────────────────────────────────────────────────────
/// 监听所有音效
@riverpod
Stream<List<Sound>> allSounds(Ref ref) {
return ref.watch(soundRepositoryProvider).watchAll();
}
/// 监听指定类型音效
@riverpod
Stream<List<Sound>> soundsByType(Ref ref, int typ) {
return ref.watch(soundRepositoryProvider).watchByType(typ);
}
/// 监听指定音效
@riverpod
Stream<Sound?> soundById(Ref ref, int id) {
return ref.watch(soundRepositoryProvider).watchById(id);
}