Skip to content

More helpful F1 help or code completion for closures as arguments #3818

Open
@filiph

Description

@filiph

Steps to Reproduce

  1. Start writing any of the widgets that take a closure (AnimatedBuilder, StreamBuilder, FutureBuilder, ListView.builder, LayoutBuilder, CupertinoTabScaffold, etc.).

  2. Check parameters (Cmd-P). Notice how the closure doesn't have any type information. Even if it did, it would be something like IndexedWidgetBuilder or TransitionBuilder or ControlsWidgetBuilder, which doesn't make it obvious what the parameters are. (The only immediately obvious to me is VoidCallback but that's learned.)

    Screen Shot 2019-08-26 at 5 44 09 PM

  3. Start writing the widget arguments. Here, if you remember not to tab-complete immediately, you can see what the closure should look like. To be honest, the first time I noticed that is today, when documenting this user journey.

    Screen Shot 2019-08-26 at 5 44 32 PM

  4. After you tab-complete and have builder: (or onTap: or whatever), now you can access the signature of the closure anymore. Cmd-P gives back the untyped view:

    Screen Shot 2019-08-26 at 5 44 42 PM

Expected behavior

Sorted by desirability, ascending:

A) The typedef of the closure is shown in the Cmd-P window.

B) The full signature of the closure is shown in the Cmd-P window.

C) The closure is written for me, and the cursor gets transported inside the body. For example, in the AnimatedBuilder example above, I write builder: and (context, child) {} is written. The arguments are named after the typedef signature.

D) Same as above, but the closure is only suggested, so I can provide a member method instead of writing inline, without first deleting the auto-completion.

Version info

Please paste the output of running flutter doctor -v here (available from the command
line or from Tools > Flutter > Flutter Doctor). It will provide the version of the
Flutter framework as well as of the IntelliJ plugin.

flutter doctor -v
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.6 18G87, locale en-US)
    • Flutter version 1.7.8+hotfix.4 at /Users/filiph/dev/flutter
    • Framework revision 20e59316b8 (6 weeks ago), 2019-07-18 20:04:33 -0700
    • Engine revision fee001c93f
    • Dart version 2.4.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/filiph/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.2, Build version 10E125
    • CocoaPods version 1.7.5

[✓] iOS tools - develop for iOS devices
    • ios-deploy 1.9.4

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 38.2.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] VS Code (version 1.36.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.2.0

[✓] Connected device (1 available)
    • Pixel 2 XL • 711KPZK0592485 • android-arm64 • Android 9 (API 28)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions