refa: danmaku & feat: scroll fixed velocity (#1791)

This commit is contained in:
My-Responsitories
2025-12-29 21:03:24 +08:00
committed by GitHub
parent 0a40d11133
commit 49b7ea14c3
15 changed files with 721 additions and 770 deletions

View File

@@ -0,0 +1,28 @@
import 'package:collection/collection.dart';
import 'package:hive/hive.dart';
extension BoxExt<E> on Box<E> {
bool equal(dynamic key, E value) {
return const DeepCollectionEquality().equals(value, get(key));
}
Future<void>? putNE(dynamic key, E value) {
if (!equal(key, value)) {
return put(key, value);
}
return null;
}
Future<void>? putAllNE(Map<dynamic, E> entries) {
final Map<dynamic, E> newEntries = {};
entries.forEach((key, value) {
if (!equal(key, value)) {
newEntries[key] = value;
}
});
if (newEntries.isNotEmpty) {
return putAll(newEntries);
}
return null;
}
}