flutter / flutter/flutter-intellij

More helpful F1 help or code completion for closures as arguments

Open
#3,818 3 comments 22 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2k
Forks
356
Avg merge
1d 11h
Merged PRs (30d)
27

Description

## 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](https://user-images.githubusercontent.com/919717/63732653-1a7b9880-c82a-11e9-9024-2c77e0c27bb4.png)

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](https://user-images.githubusercontent.com/919717/63732692-4f87eb00-c82a-11e9-9c4a-0767750503d2.png)

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](https://user-images.githubusercontent.com/919717/63732727-76462180-c82a-11e9-844a-8a04416add94.png)

### 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!
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.