facebookShareLink static method Null safety

Future<String?> facebookShareLink(
  1. {String? quote,
  2. required String url,
  3. OnSuccessHandler? onSuccess,
  4. OnCancelHandler? onCancel,
  5. OnErrorHandler? onError}
)

Implementation

static Future<String?> facebookShareLink({
  String? quote,
  required String url,
  OnSuccessHandler? onSuccess,
  OnCancelHandler? onCancel,
  OnErrorHandler? onError,
}) async {
  _channel.setMethodCallHandler((MethodCall call) async{
    switch (call.method) {
      case "onSuccess":
        if (onSuccess != null){
          return onSuccess(call.arguments);
        }
        break;
      case "onCancel":
        if (onCancel != null) {
          return onCancel();
        }
        break;
      case "onError":
      if (onError != null) {
        return onError(call.arguments);
      }
      break;
      default:
        throw UnsupportedError("Unknown method called");
    }
    return call.arguments;
  });
  return _channel.invokeMethod<String>('facebookShareLink', <String, dynamic>{
    'quote': quote,
    'url': url,
  });
}