Skip to content

Inline factory constructor #60097

@stephane-archer

Description

@stephane-archer
@immutable
class LutPreviewArg extends Equatable {
  final LutInterpolation interpolation;
  final PreviewGeneratorNotifier previewGeneratorNotifier;
  final RefImageEditedBeforeLutPathArg refImageEditedBeforeLutPathArg;
  final String? selectedLutPath;
  final double lutIntensity;

  const LutPreviewArg({
    required this.interpolation,
    required this.lutIntensity,
    required this.previewGeneratorNotifier,
    required this.refImageEditedBeforeLutPathArg,
    required this.selectedLutPath,
  });

  factory LutPreviewArg.exportQuality({
    required final PreviewGeneratorNotifier previewGeneratorNotifier,
    required final String selectedLutPath,
    required final String? refImagePath,
    required final double brightness,
    required final num temperature,
    required final double lutIntensity,
  }) {
    return LutPreviewArg.flatConstructor(
      brightness: brightness,
      temperature: temperature,
      interpolation: LutInterpolation.trilinear,
      lutIntensity: lutIntensity,
      previewGeneratorNotifier: previewGeneratorNotifier,
      refImagePath: refImagePath,
      resolution: null,
      selectedLutPath: selectedLutPath,
    );
  }

  factory LutPreviewArg.flatConstructor({
    required final LutInterpolation interpolation,
    required final PreviewGeneratorNotifier previewGeneratorNotifier,
    required final String selectedLutPath,
    required final String? refImagePath,
    required final double brightness,
    required final num temperature,
    required final double lutIntensity,
    required final Resolution? resolution,
  }) {
    final refImageEditedBeforeLutPathArg =
        RefImageEditedBeforeLutPathArg(
      brightness: brightness,
      temperature: temperature,
      refImagePath: refImagePath,
      resolution: resolution,
    );
    return LutPreviewArg(
      interpolation: interpolation,
      lutIntensity: lutIntensity,
      previewGeneratorNotifier: previewGeneratorNotifier,
      refImageEditedBeforeLutPathArg: refImageEditedBeforeLutPathArg,
      selectedLutPath: selectedLutPath,
    );
  }

  factory LutPreviewArg.fromProviders(final WidgetRef ref,
      {required final LutInterpolation interpolation,
      required final Resolution? resolution,
      required final double lutIntensity}) {
    final PreviewGeneratorNotifier previewGeneratorNotifier =
        ref.watch(previewGeneratorProvider.notifier);
    final String? selectedLutPath =
        ref.watch(selectedLutPathProvider).selectedLutPath;
    return LutPreviewArg(
      interpolation: interpolation,
      lutIntensity: lutIntensity,
      previewGeneratorNotifier: previewGeneratorNotifier,
      refImageEditedBeforeLutPathArg:
          RefImageEditedBeforeLutPathArg.fromProviders(ref,
              resolution: resolution),
      selectedLutPath: selectedLutPath,
    );
  }

  @override
  List<Object?> get props {
    return [
      interpolation,
      lutIntensity,
      previewGeneratorNotifier,
      refImageEditedBeforeLutPathArg,
      selectedLutPath,
    ];
  }
}

inline flatConstructor in exportQuality (flatConstructor is only use here in the code base)
error:
Method declaration or reference must be selected to activate this refactoring.

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-refactoringIssues with analysis server refactoringstype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions