Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dart code snippets #11310

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/content/tools/vs-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,25 @@ The Flutter extension includes the following snippets:
and its associated State subclass including a field initialized
with an `AnimationController`.

The Dart extension includes the following snippets:

| Prefix | Description | Code Example |
|---|---|---|
| `main` | Insert a main function, used as an entry point. | `void main(List<String> args) { }` |
| `try` | Insert a try/catch block. | `try { } catch (e) { }` |
| `if` | Insert an if statement. | `if (condition) { }` |
| `ife` | Insert an if statement with an else block. | `if (condition) { } else { }` |
| `switch` | Insert a switch statement. | `switch (variable) { case value1: break; case value2: break; default: }` |
| `for` | Insert a for loop. | `for (var i = 0; i < 10; i++) { }` |
| `fori` | Insert a for-in loop. | `for (var item in list) { }` |
| `while` | Insert a while loop. | `while (condition) { }` |
| `do` | Insert a do-while loop. | `do { } while (condition);` |
| `fun` | Insert a function definition. | `void myFunction(String name) { }` |
| `class` | Insert a class definition. | `class MyClass { }` |
| `typedef` | Insert a typedef. | `typedef MyFunction = void Function(String);` |
| `test` | Insert a test block. | `test('My test description', () { });` |
| `group` | Insert a test group block. | `group('My test group', () { });` |

You can also define custom snippets by executing
**Configure User Snippets** from the [Command Palette][].

Expand Down
Loading