ffmpeg-kit icon indicating copy to clipboard operation
ffmpeg-kit copied to clipboard

In flutter library provide a properties getters and setters in dart syntax, as a property, instead of methods get*() and set*()

Open Nashev opened this issue 1 year ago • 1 comments

See https://dart-dev.web.app/language/methods#getters-and-setters to understand what I mean.

Now Your implementation contains access methods in form of pairs like this:

  static FFprobeSessionCompleteCallback? getGlobalFFprobeSessionCompleteCallback() => _ffprobeSessionCompleteCallback;

  static void setGlobalFFprobeSessionCompleteCallback(FFprobeSessionCompleteCallback? completeCallback) {
    _ffprobeSessionCompleteCallback = completeCallback;
  }

For backward compatibility I suggest to leave existing methods with @Deprecated() directive. So I would like to see something like this in next few releases:

  static FFprobeSessionCompleteCallback? get globalFFprobeSessionCompleteCallback => _ffprobeSessionCompleteCallback;
  static set globalFFprobeSessionCompleteCallback(FFprobeSessionCompleteCallback? completeCallback) => 
      _ffprobeSessionCompleteCallback = completeCallback;

  @Deprecated('Use property globalFFprobeSessionCompleteCallback instead of this getter, it makes shorter code.')
  static FFprobeSessionCompleteCallback? getGlobalFFprobeSessionCompleteCallback() => globalFFprobeSessionCompleteCallback;

  @Deprecated('Use property globalFFprobeSessionCompleteCallback instead of this setter, it makes shorter code.')
  static void setGlobalFFprobeSessionCompleteCallback(FFprobeSessionCompleteCallback? completeCallback) {
    globalFFprobeSessionCompleteCallback = completeCallback;
  }

And finally leave only this:

  static FFprobeSessionCompleteCallback? get globalFFprobeSessionCompleteCallback => _ffprobeSessionCompleteCallback;

  static set globalFFprobeSessionCompleteCallback(FFprobeSessionCompleteCallback? completeCallback) =>
      _ffprobeSessionCompleteCallback = completeCallback;

It will allow use a form like

  FFmpegKitFactory.globalFFprobeSessionCompleteCallback = myMethod;
// and
  if (FFmpegKitFactory.globalFFprobeSessionCompleteCallback != null)

instead of

  FFmpegKitFactory.setGlobalFFprobeSessionCompleteCallback(myMethod);
// and 
  if (FFmpegKitFactory.getGlobalFFprobeSessionCompleteCallback() != null)

not so big changes, but it will more dart-styled code. It is worth.

Nashev avatar Apr 27 '24 12:04 Nashev

I do accept that some of the method names don't adhere to the language-specific best practices. However, this decision was intentional to maintain uniformity in method names across all platforms. We intend to stay behind this philosophy unless it compromises functionality at some point.

tanersener avatar Apr 27 '24 15:04 tanersener