Skip to content

[Bug report] extract method: The argument type 'void Function(SnackBarData)' can't be assigned to the parameter type 'void Function(dynamic)' #5350

@stephane-archer

Description

@stephane-archer

Input:

        var snackBarData = await _executeConversionWithExceptionAsValue(
          () async {
            await JxlToJpeg.convert(
              jxlFile,
              outputPath: path_lib.join(
                selectedOutputDirPath,
                path_lib.setExtension(path_lib.basename(jxlFile.path), '.jpg'),
              ),
            );
          },
        );
        if (snackBarData != null) {
          displayFeedbackForTheUser(snackBarData);
        }
        _progress.value += 1;

extract method _abc

Result:

  Future<void> _abc(File jxlFile, String selectedOutputDirPath, void displayFeedbackForTheUser(SnackBarData )) async {
    var snackBarData = await _executeConversionWithExceptionAsValue(
      () async {
        await JxlToJpeg.convert(
          jxlFile,
          outputPath: path_lib.join(
            selectedOutputDirPath,
            path_lib.setExtension(path_lib.basename(jxlFile.path), '.jpg'),
          ),
        );
      },
    );
    if (snackBarData != null) {
      displayFeedbackForTheUser(snackBarData);
    }
    _progress.value += 1;
  }

The argument type 'void Function(SnackBarData)' can't be assigned to the parameter type 'void Function(dynamic)'.

Correct output:

  Future<void> _abc(File jxlFile, String selectedOutputDirPath, void Function(SnackBarData) displayFeedbackForTheUser) async {
    var snackBarData = await _executeConversionWithExceptionAsValue(
      () async {
        await JxlToJpeg.convert(
          jxlFile,
          outputPath: path_lib.join(
            selectedOutputDirPath,
            path_lib.setExtension(path_lib.basename(jxlFile.path), '.jpg'),
          ),
        );
      },
    );
    if (snackBarData != null) {
      displayFeedbackForTheUser(snackBarData);
    }
    _progress.value += 1;
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bugrelies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions