Skip to content

useless The argument type 'String?' can't be assigned to the parameter type 'String'. #59820

Closed
@stephane-archer

Description

@stephane-archer
class _SmartExposureAnalysisWidget extends StatelessWidget {
  const _SmartExposureAnalysisWidget({
    required this.pathImgSelectedLut,
    required this.imagePath,
    required this.previewGeneratorChangeNotifier,
  });

  final String? pathImgSelectedLut;
  final String? imagePath;
  final PreviewGeneratorChangeNotifier previewGeneratorChangeNotifier;

  @override
  Widget build(BuildContext context) {
    if (imagePath == null) {
      return const SizedBox.shrink();
    }
    if (pathImgSelectedLut == null) {
      return ExposureAnalysisWidget(
          imagePath, previewGeneratorChangeNotifier);
    }
    return ExposureAnalysisWidget(
        pathImgSelectedLut, previewGeneratorChangeNotifier);
  }
}

The argument type 'String?' can't be assigned to the parameter type 'String'.

Because imagePath is final and is checked for null in the build function, I don't see why I should have a ! or a local variable to avoid this error message.

Am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-uxdevexp-warningIssues with the analyzer's Warning codestype-questionA question about expected behavior or functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions