registerFeatureFlagListener method Null safety

Future<bool?> registerFeatureFlagListener(
  1. String? flagKey,
  2. void callback(
    1. String?
    )?
)

Registers a callback to be called when the flagKey changes from its current value. If the feature flag is deleted, the listener will be unregistered.

flagKey the flag key to attach the listener to callback the listener to attach to the flag key

Implementation

Future<bool?> registerFeatureFlagListener(
    String? flagKey, void Function(String?)? callback) async {
  if (flagKey == null || callback == null) {
    return false;
  }

  if (flagListeners!.containsKey(flagKey)) {
    flagListeners![flagKey] = callback;
    return true;
  }

  flagListeners![flagKey] = callback;
  return await _channel.invokeMethod(
      'registerFeatureFlagListener', <String, dynamic>{'flagKey': flagKey});
}