Skip to content

Commit 1599dc7

Browse files
committed
🚀 Expose observe register methods.
1 parent d69d6e2 commit 1599dc7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lib/src/widget/asset_picker.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,28 @@ class AssetPicker extends StatelessWidget {
127127
}
128128
}
129129

130+
/// Register observe callback with assets changes.
131+
/// 注册资源(图库)变化的监听回调
132+
static void registerObserve([ValueChanged<MethodCall> callback]) {
133+
try {
134+
PhotoManager.addChangeCallback(callback);
135+
PhotoManager.startChangeNotify();
136+
} catch (e) {
137+
realDebugPrint('Error when registering assets callback: $e');
138+
}
139+
}
140+
141+
/// Unregister observe callback with assets changes.
142+
/// 取消注册资源(图库)变化的监听回调
143+
static void unregisterObserve([ValueChanged<MethodCall> callback]) {
144+
try {
145+
PhotoManager.removeChangeCallback(callback);
146+
PhotoManager.stopChangeNotify();
147+
} catch (e) {
148+
realDebugPrint('Error when unregistering assets callback: $e');
149+
}
150+
}
151+
130152
/// Whether the current platform is Apple OS.
131153
/// 当前平台是否苹果系列系统 (iOS & MacOS)
132154
bool get isAppleOS => Platform.isIOS || Platform.isMacOS;

0 commit comments

Comments
 (0)