Skip to content

required keyword on lambda suggestion #4834

Closed

Description

@FMorschel

Is your feature request related to a problem? Please describe.
I have the following class in my Flutter project:

class DataRowCubit<T> extends Cubit<List<DataRow>> {
  DataRowCubit({
    required DataRow Function({
      required bool selected,
      required T data,
      required int index,
      // ignore: avoid_positional_boolean_parameters, single parameter
      required void Function(bool?) onSelectionChanged,
    }) dataRow,
    void Function({
      required bool? selection,
      required int index,
      required List<bool> list,
    })? onSelectionChanged,
    List<T>? list,
  })
//...

But when I write down the constructor to create a new instance, the suggested fillings for the lambdas are the following:

image

This creates a minor inconvenience that I then need to write down the requireds myself in all of the non-null parameters:

image

Describe the solution you'd like
I would like for the suggested code to follow the required keyword.

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Nov 10, 2023
  2. added this to the v3.78.0 milestone on Nov 14, 2023
  3. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
    on Nov 14, 2023
  4. DanTup commented on Nov 14, 2023

    @DanTup
    Member

    Working on a fix at https://dart-review.googlesource.com/c/sdk/+/336021

    required.mp4
  5. DanTup commented on Nov 15, 2023

    @DanTup
    Member

    Fixed by dart-lang/sdk@4dddc98 - will in a future SDK (not Dart-Code) release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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 enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.relies 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