mobx.dart icon indicating copy to clipboard operation
mobx.dart copied to clipboard

Invalid function arguments types in generated file

Open jayachandra572 opened this issue 3 years ago • 1 comments

actual function

Future<dynamic> loginUserOTPApi( {required LoginRequest data, void Function()? onSuccess, void Function(String error)? onFailure}) { }

generated function

@override Future<dynamic> loginUserOTPApi( {required LoginRequest data, void Function() onSuccess, void Function(String) onFailure}) { final _$actionInfo = _$_AuthStoreActionController.startAction( name: '_AuthStore.loginUserOTPApi'); try { return super.loginUserOTPApi( data: data, onSuccess: onSuccess, onFailure: onFailure); } finally { _$_AuthStoreActionController.endAction(_$actionInfo); } }

jayachandra572 avatar Oct 29 '21 16:10 jayachandra572

This problem is still happening. It is unable to convert a method that receives a nullable function (with some arguments in my case), for example in the refreshToken function:

Future<bool> refreshToken({
    VoidCallback? onSuccess,
    void Function([
      String? title,
      String? content,
      String? debugInfo,
    ])? onFail,
  }) {
   ...
}

onFail is a nullable function with some arguments and when I run the command to automatically generate the store, it generates it like this:

Future<bool> refreshToken(
      {VoidCallback? onSuccess,
      void Function([String?, String?, String?]) onFail})

instead of generating it like this:

Future<bool> refreshToken(
      {VoidCallback? onSuccess,
      void Function([String?, String?, String?])? onFail})

The difference is the question mark before the argument name "onFail". Please fix this.

pedrostick3 avatar Feb 15 '24 19:02 pedrostick3