Skip to content

Commit

Permalink
Add Dart code snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhnwin authored Oct 23, 2024
1 parent fdf47ff commit c8b7d3e
Showing 1 changed file with 19 additions and 0 deletions.
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

0 comments on commit c8b7d3e

Please sign in to comment.