igaurab/user_location_plugin

Compass stream not canceled

Closed this issue · 0 comments

User direction had been added by the following pull request: [https://github.com//pull/31] but the compass stream is not canceled on dispose.
I suggest changing this line

FlutterCompass.events.listen((double direction);

to

_compassStreamSubscription = FlutterCompass.events.listen((double direction);

so that subscription could be declared as

StreamSubscription<double> _compassStreamSubscription;

and canceled in dispose

@override
void dispose() {
    _compassStreamSubscription.cancel();
   ...