Skip to content

Commit e21f87d

Browse files
committed
Refactor app change event handling by simplifying stream management and removing redundant methods in FlutterDeviceAppsPlatform.
1 parent 7698b4f commit e21f87d

1 file changed

Lines changed: 3 additions & 21 deletions

File tree

lib/flutter_device_apps_platform_interface.dart

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,10 @@ abstract class FlutterDeviceAppsPlatform extends PlatformInterface {
128128
///
129129
/// Platform implementations should emit [AppChangeEvent] objects when apps
130130
/// are installed, removed, or updated on the device.
131-
/// Call [startAppChangeStream] to begin receiving events.
132-
Stream<AppChangeEvent> get appChanges;
133-
134-
/// Starts monitoring for app change events.
135-
///
136-
/// Call this method to begin receiving app change events via [appChanges] stream.
137-
/// Platform implementations should set up necessary listeners or broadcast receivers.
138-
Future<void> startAppChangeStream();
139-
140-
/// Stops monitoring for app change events.
141131
///
142-
/// Call this method to stop receiving app change events and clean up resources.
143-
/// Platform implementations should remove listeners or unregister broadcast receivers.
144-
Future<void> stopAppChangeStream();
132+
/// The stream automatically starts listening when the first subscriber is added
133+
/// and stops when all subscribers are removed (broadcast stream behavior).
134+
Stream<AppChangeEvent> get appChanges;
145135

146136
/// Opens the app settings for the specified package name.
147137
///
@@ -186,14 +176,6 @@ class _UnimplementedPlatform extends FlutterDeviceAppsPlatform {
186176
Stream<AppChangeEvent> get appChanges =>
187177
Stream.error(UnsupportedError('FlutterDeviceAppsPlatform not implemented'));
188178

189-
@override
190-
Future<void> startAppChangeStream() =>
191-
Future.error(UnsupportedError('FlutterDeviceAppsPlatform not implemented'));
192-
193-
@override
194-
Future<void> stopAppChangeStream() =>
195-
Future.error(UnsupportedError('FlutterDeviceAppsPlatform not implemented'));
196-
197179
@override
198180
Future<bool> openAppSettings(String packageName) =>
199181
Future.error(UnsupportedError('FlutterDeviceAppsPlatform not implemented'));

0 commit comments

Comments
 (0)