VS Code extensions v3.10 - Main method CodeLens, Test on device, Custom emulator launching

20 views
Skip to first unread message

Danny Tuppeny

unread,
May 1, 2020, 11:19:41 AM5/1/20
to Flutter Dev

Hi all,

v3.10.0 of the Dart & Flutter VS Code extensions are live. Release notes below (and online). If you find any issues, please file them on GitHub.

Main Method CodeLens

#2356/#2359/#2373 CodeLens links are now available on main() methods for both applications and test scripts. This allows running the current file even if the current launch configuration specifies another script. These links can be toggled using the dart.showMainCodeLens setting.

The template field in a launch config (see below for an example) has been extended to support templating these CodeLens.

  • run-test applies to test() and group() CodeLens, runs without debugging
  • debug-test applies to test() and group() CodeLens, runs with debugging
  • run-test-file applies to main() CodeLens in test files, runs without debugging
  • debug-test-file applies to main() CodeLens in test files, runs with debugging
  • run-file applies to main() CodeLens in non-test files, runs without debugging
  • debug-file applies to main() CodeLens in non-test files, runs with debugging

Run Tests on Device

#2363/#2374: A new launch config flag runTestsOnDevice has been added that allows you to create launch configurations that will run tests with flutter run on the select device instead of using flutter test.

Using the two features above together, you can add CodeLens links to easily run test scripts on a device:

{
	"version": "0.2.0",
	"configurations": [
		{
			"name": "Flutter App",
			"request": "launch",
			"type": "dart"
		},
		{
			"name": "Debug Tests on Device",
			"request": "launch",
			"type": "dart",
			"runTestsOnDevice": true,
			// This adds this config to CodeLens for test files
			"template": "debug-test-file"
		}
	]
}

Pub: List Outdated Packages

#2322/#2350: A new Dart: List Outdated Packages command has been added that runs pub outdated. It’s also available on the context menu and editor toolbar for the pubspec.yaml file.

This command will only show up when using >= v2.8 of the Dart SDK.

Custom Emulators

#1553/#2360/#2319: It’s now possible to add third party emulators that don’t show up in flutter emulators to the device selector using the dart.flutterCustomEmulators setting. The emulator must still show up in flutter devices once it’s been launched for it to be used to launch an app:

"dart.flutterCustomEmulators": [
	{
		"id": "my-emu",
		"name": "My Emulator",
		"executable": "/path/to/emulator",
		"args": ["--launch"]
	}
]

This setting also allows the command/args used to launch existing Flutter emulators to be overriden by using the same ID. For example, to force an existing Android emulator with the ID Pixel_2_XL_API_29 to run with -gpu host you can override its command/args:

{
	"id": "Pixel_2_XL_API_29",
	"name": "Pixel 2",
	"executable": "/Users/danny/Library/Android/sdk/emulator/emulator",
	"args": ["-avd", "Pixel_2_XL_API_29", "-gpu", "host"]
}

Editor

  • #1991: Holding <shift> when accepting code completions will now always insert completion text (rather than replacing text immediately to the right of the cursor). Which mode is default can be controlled by setting the editor.suggest.insertMode for [dart] in your user settings.
  • #2387: Errors and lints will now have clickable error codes (where available) to open a web page containing more information about the error/lint.
  • #2169: Key-binding is now available for both fixes and refactors (see refactorings and code fixes, though note that all IDs may not work unless you’re using a very recent SDK version).
  • #956: Closing Labels will now appear/disappear more reliably when enabling/disabling without restarting the editor.
  • #2323: Symbols are no longer doubled in the workspace symbol list if dart.additionalAnalyzerFileExtensions includes .dart or duplicates.
  • #2378: The Dart: Sort Members command now works when the LSP preview is enabled.

Debugger

  • #2146Maps with complex keys (such as DateTimes) are now shown correctly in debug views like Watch and Variables.
  • #1990: The debugger Copy value action no longer adds " around string values.
  • #1246: Debug views will now automatically call toString() on complex types. This can be controlled with the dart.evaluateToStringInDebugViews setting.
  • #1021: The watch window will now show “not available” instead of an error message for variables that are not available at the current location.
  • #2389: Clicking the debugger Stop button too soon after starting a Flutter debug session should no longer result in the app continuing to build and launch. However, there may be a short delay before the process terminates.
  • #2403: Evaluating invalid expressions in the Debug Console will now show more specific error messages than “Expression compilation error”.
  • #2404: Trailing semicolons will now be ignored when evaluating expressions to avoid unnecessary expression compilation errors.
  • #2361: A warning will now be shown when launching an app if the casing of the cwd/program fields do not match the casing on the underlying file system.

Testing

  • #2380: Clicking Stop when paused in a test will now show a more obvious “Waiting for test to complete” notification.
  • #2385: Clicking Stop when paused in a test will now automatically disable breakpoints and resume the test to allow it to complete and the session to end cleanly.
  • #2362test()s and group()s with variables in the name are now runnable from CodeLens links with some caveats.
  • #2349: Running tests from the test tree and with the Dart: Run Test at Cursor command is now possible even if another debug session is running.
  • #2351: The flutter_test package is no longer incorrectly marked as user-code so will not be debuggable when in Debug my code mode.
  • #2343: Running tests in the Dart SDK repo now (again) uses the VM directly.
  • #2335: Running tests in a folder named test for a non-web project will no longer show a spurious error about not being supported.

Commands

  • #2336: The Flutter: Run Flutter Doctor command no longer writes to an output window that is hidden by default.
  • #2377: The Dart: Run all Tests command now works when your projects are in sub-folders of the open workspace.
  • #2285/#2369BootBlock contributed a new Dart: Rerun Last Test Session command which works like Dart: Rerun Last Debug Session but only considering recent test debug sessions.

Remoting Support

  • #2376: Joining a Live Share session will no longer show a warning about editing loose Dart files.
  • #2092/#2353: Flutter web debugging works when in a VS Code remoting session via the Dart Debug extension. This requires >= v1.18.0-5.0 of the Flutter SDK.

Other

  • #2310: Invalid log paths (eg. copied from other machines) no longer result in activation failures with cryptic error messages.

TruongSinh Tran-Nguyen

unread,
May 3, 2020, 12:19:14 PM5/3/20
to Flutter Development (flutter-dev)
Hi, Dart extension (the language feature, https://dart.dev/guides/language/extension-methods) is not yet in this release, right?

Danny Tuppeny

unread,
May 4, 2020, 8:51:09 AM5/4/20
to Flutter Development (flutter-dev)
The VS Code extension is seperate to the Dart SDK version. As long as you're using a version of the Dart SDK that supports extension methods (>= v2.7) they should work in VS Code (even before this latest release).

If you're editing a Dart project, the SDK version will be shown in the status bar. If you're editing a Flutter project, you can check which version of Dart it includes by running flutter --version.

If something doesn't seem to work and you think it should, file an issue on GitHub and I'll take a look. Thanks!

TruongSinh Tran-Nguyen

unread,
May 4, 2020, 12:58:59 PM5/4/20
to Danny Tuppeny, Flutter Development (flutter-dev)
Thanks,

I have filled https://github.com/Dart-Code/Dart-Code/issues/2420 with flutter doctor and screenshot

Kind regards,
Sinh


TruongSinh Tran-Nguyen, PMI-ACP, PSM III, PSPO II

Tech Visionary, Craftsman, Coach and Investor

+1-6127-TR-SINH (+1-6127-87-7464) | truon...@smarpsocial.com | @truongsinhtn

Find me on LinkedIn | Twitter | Github | StackOverflow

IBAN: GB90 REVO 0099 7073 9238 05 | BIC: REVOGB21




--
You received this message because you are subscribed to a topic in the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/flutter-dev/a0Xjpa60Zgg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/53367802-a93d-433a-b3da-5c7767762cd7%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages