MethodChannelFanmeter constructor
MethodChannelFanmeter()
Constructs a MethodChannelFanmeter.
Implementation
MethodChannelFanmeter() {
// We only register the handler once in the constructor
//to avoid overwriting the callbacks when making multiple subscriptions.
//This ensures that all events received are correctly routed
//to the callback associated with the corresponding eventId.
methodChannel.setMethodCallHandler((call) async {
if(call.method == 'onUserParticipationChanged') {
final Map<dynamic, dynamic> args = call.arguments;
final int eventId = args['eventId'];
final int value = args['value'];
final callback = _userParticipationCallback[eventId];
if(callback != null) {
callback(value);
}
}
});
}