From 28b1dd989f41b1c1b4547c0b9509baedffc1e3ae Mon Sep 17 00:00:00 2001 From: Plague Fox Date: Thu, 22 Aug 2024 15:32:23 +0400 Subject: [PATCH 1/5] chore: Update package.json version to 0.4.0 --- README.md | 83 ++++++++++++++++++++++++++++++++++++++++ package.json | 6 ++- snippets/dart.json | 84 +++++++++------------------------------- snippets/flutter.json | 87 +++++++++++++++++++++++++++++++----------- snippets/markdown.json | 44 +++++++++++++++++++++ 5 files changed, 215 insertions(+), 89 deletions(-) create mode 100644 snippets/markdown.json diff --git a/README.md b/README.md index d89471d..d896ea2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,86 @@ # Flutter Plus Extension add some useful commands to Flutter development in Visual Studio Code. + +## Markdown snippets + +| Shortcut | Description | +| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| unreleased | Create a new unreleased section. Used to list features that are not yet released. | +| version | Create a new version section. Used to list features that are released in a specific version. | + + +## Dart snippets + +| Shortcut | Description | +| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| main | Create a new main function. The entry point of a Dart app. | +| try | Create a new try-catch block. Used to handle exceptions. | +| timeout | Create a new timeout block. Used to handle timeouts. | +| stopwatch | Create a new Stopwatch. Used to measure elapsed time. | +| conditional_imports | Create a new conditional import. Used to import a library based on a current environment (VM or JS) | +| dvd | Divider comment line. Used to separate sections of code. | +| reverseList | Create a new reverse list function. Reverse list traversal in a loop. | +| part | Create a new part directive. Used to specify a URI where part of the library is located. | +| mocks | Import mocks file. Used to import a file with mocks. | +| equals | Hash code and equals methods. Used to override the `==` operator and the `hashCode` getter. | +| nosm | Create a new noSuchMethod method. Used to implement the `noSuchMethod` method. | +| test | Create a new test function. Used to define a test case. | +| pragma | Create a new pragma directive. Used to specify options that affect the behavior of the Dart compiler. | +| doc-disabled | Create a new disabled documentation comment. Used to disable a block of documentation comments. | +| doc-category | Create a new category documentation comment. Used to categorize a block of documentation comments. | +| doc-image | Create a new image documentation comment. Used to add an image to a block of documentation comments. | +| doc-animation | Create a new animation documentation comment. Used to add an animation to a block of documentation comments. | +| doc-html | Create a new HTML documentation comment. Used to add HTML to a block of documentation comments. | +| newtmpl | Creates a new dartdoc template with current file's name as its prefix. | +| usetmpl | Uses existing dartdoc macro with current file's name as its prefix. | +| deprecated | Create a new deprecated annotation. Used to mark a class, method, or property as deprecated. | +| meta | Create a new meta annotation. Used to annotate a class, method, or property with metadata. | +| coverage | Create a comment line for coverage. Used to mark a line or block of code that is not covered by tests. | + + +## Flutter snippets + +| Shortcut | Description | +| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| mateapp | Create a new MaterialApp widget. An application that uses Material Design. | +| cupeapp | Create a new CupertinoApp widget. An application that uses Cupertino design. | +| scaffold | Create a new Scaffold widget. Implements the basic Material Design visual layout structure. | +| stl | Create a new StatelessWidget. A widget that does not require mutable state. | +| stlChild | Create a new StatelessWidget with a child. A widget that does not require mutable state. | +| stf | Create a new StatefulWidget. A widget that has mutable state. | +| stfChild | Create a new StatefulWidget with a child. A widget that has mutable state. | +| inh | Create a new InheritedWidget. Base class for widgets that efficiently propagate information down the tree. | +| of | Create a new static `of` method for an InheritedWidget. Returns the nearest widget of the given type T and creates a dependency on it, or null if no appropriate widget is found. | +| stateOf | Create a new static `stateOf` method for an State object. Returns the State object of the nearest ancestor StatefulWidget widget that is an instance of the given type T. | +| widgetOf | Create a new static `widgetOf` method for an Widget object. Returns the nearest ancestor widget of the given type T, which must be the type of a concrete Widget subclass. | +| painter | Create a new CustomPainter. A widget that provides a canvas on which to draw during the paint phase. Used for drawing custom shapes. | +| clipper | Create a new CustomClipper. Used for creating custom shapes. | +| debugFillProperties | Create a new debugFillProperties method. Add additional properties associated with the node. | +| initS | Create a new initState method. Called when this object is inserted into the tree. The framework will call this method exactly once for each State object it creates. | +| dispose | Create a new dispose method. Called when this object is removed from the tree permanently. The framework calls this method when this State object will never build again. | +| reassemble | Create a new reassemble method. Called whenever the application is reassembled during debugging, for example during hot reload. | +| didChangeD | Create a new didChangeDependencies method. Called when a dependency of this element changes. | +| didUpdateW | Create a new didUpdateWidget method. Called whenever the widget configuration changes. | +| build | Create a new build method. Describes the part of the user interface represented by this widget. | +| listViewBuilder | Create a new ListView.builder. A scrollable list that works with a list of children. | +| listViewSeparated | Create a new ListView.separated. A scrollable list that works with a list of children separated by a divider. | +| gridViewBuilder | Create a new GridView.builder. A scrollable, 2D array of widgets. | +| gridViewCount | Create a new GridView.count. A scrollable, 2D array of widgets with a fixed number of tiles in the cross axis. | +| gridViewE | Create a new GridView.extent. A scrollable, 2D array of widgets with a maximum number of tiles in the cross axis. | +| customScrollV | Create a new CustomScrollView. A ScrollView that creates custom scroll effects using slivers. | +| builder | Create a new Builder. A widget that delegates its building to a callback. | +| wrapWithBuilder | Wrap the selected widget with a Builder. A widget that delegates its building to a callback. | +| stfBuilder | Create a new StatefulWidget with a Builder. A widget that has mutable state and delegates its building to a callback. | +| strBuilder | Create a new StreamBuilder. A widget that builds itself based on the latest snapshot of interaction with a Stream. | +| lisBuilder | Create a new ListenableBuilder. A widget that builds itself based on the latest value of a Listenable it listens to. | +| valLisBuilder | Create a new ValueListenableBuilder. A widget that builds itself based on the latest value of a ValueListenable it listens to. | +| animBuilder | Create a new AnimatedBuilder. A general-purpose widget for building animations. | +| switcher | Create a new AnimatedSwitcher. A widget that switches between two children and animates the transition. | +| orientBuilder | Create a new OrientationBuilder. A widget that builds itself based on the latest orientation of the device. | +| layBuilder | Create a new LayoutBuilder. A widget that builds itself based on the latest layout constraints. | +| repBound | Create a new RepaintBoundary. A widget that isolates repaints, so that a repaint of one child is separate from other children. | +| singleChildSV | Create a new SingleChildScrollView. A box in which a single widget can be scrolled. | +| futBuilder | Create a new FutureBuilder. A widget that builds itself based on the latest snapshot of interaction with a Future. | +| tweenAnimBuilder | Create a new TweenAnimationBuilder. An animation that interpolates between two animatable objects. | +| testWidget | Create a new testWidgets function for testing a widget. | \ No newline at end of file diff --git a/package.json b/package.json index faf8b39..af03f48 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Flutter Plus", "description": "Extension with various improvements for Flutter", "icon": "assets/logo.png", - "version": "0.3.0", + "version": "0.4.0", "pricing": "Free", "engines": { "vscode": "^1.92.0" @@ -72,6 +72,10 @@ "commandPalette": [] }, "snippets": [ + { + "language": "markdown", + "path": "./snippets/markdown.json" + }, { "language": "dart", "path": "./snippets/dart.json" diff --git a/snippets/dart.json b/snippets/dart.json index 3c8582e..901534a 100644 --- a/snippets/dart.json +++ b/snippets/dart.json @@ -2,7 +2,7 @@ "Main entry point": { "scope": "flutter, dart", "prefix": "main", - "description": "Main entry point", + "description": "Main entry point.", "body": [ "import 'dart:async';\n", "@pragma('vm:entry-point')", @@ -17,7 +17,7 @@ "Try-catch-finally block": { "scope": "flutter, dart", "prefix": "try", - "description": "Try-catch-finally block", + "description": "Try-catch-finally block.", "body": [ "try {", " // ...", @@ -31,13 +31,13 @@ "Timeout handler": { "scope": "flutter, dart", "prefix": "timeout", - "description": "Timeout handler", + "description": "Timeout handler.", "body": "timeout(const Duration(milliseconds: 5000))${0:;}" }, "Stopwatch": { "scope": "flutter, dart", "prefix": "stopwatch", - "description": "Stopwatch", + "description": "Stopwatch. Used to measure elapsed time.", "body": [ "final stopwatch = Stopwatch()..start();", "try {", @@ -66,55 +66,13 @@ " if (dart.library.io) 'io.dart';\n" ] }, - "Changelog unreleased": { - "scope": "md, markdown", - "prefix": [ - "changelog_unreleased", - "unreleased" - ], - "description": "Changelog unreleased", - "body": [ - "## Unreleased", - "", - "- **ADDED**: ${0}", - "- **CHANGED**: ", - "- **DEPRECATED**: ", - "- **REMOVED**: ", - "- **FIXED**: ", - "- **SECURITY**: ", - "- **REFACTOR**: ", - "- **DOCS**: ", - " " - ] - }, - "Changelog version": { - "scope": "md, markdown", - "prefix": [ - "changelog_version", - "version" - ], - "description": "Changelog version section", - "body": [ - "## ${1:0}.${2:0}.${3:0}", - "", - "- **ADDED**: ${0}", - "- **CHANGED**: ", - "- **DEPRECATED**: ", - "- **REMOVED**: ", - "- **FIXED**: ", - "- **SECURITY**: ", - "- **REFACTOR**: ", - "- **DOCS**: ", - " " - ] - }, "Divider": { "scope": "flutter, dart", "prefix": [ "dvd", "divider_comment" ], - "description": "Divider comment line", + "description": "Divider comment line. Used to separate sections of code.", "body": "// --- ${1} --- //\n\n$0" }, "Reverse bypass": { @@ -191,8 +149,8 @@ "Pragma": { "scope": "flutter, dart", "prefix": [ - "@pragma", - "pragma" + "pragma", + "@pragma" ], "description": "Pragma annotation https://mrale.ph/dartvm/pragmas.html", "body": "@pragma(${1|'vm:entry-point','vm:never-inline','vm:prefer-inline','dart2js:tryInline','vm:notify-debugger-on-exception','vm:invisible','vm:always-consider-inlining','flutter:keep-to-string','flutter:keep-to-string-in-subtypes'|})" @@ -209,9 +167,7 @@ "Dart doc category": { "scope": "flutter, dart", "prefix": [ - "category", "doc-category", - "dartdoc-category", "@doc-category" ], "description": "Add category to documentation", @@ -223,7 +179,6 @@ "scope": "flutter, dart", "prefix": [ "doc-image", - "dartdoc-image", "@doc-image" ], "description": "Add image to documentation", @@ -235,7 +190,6 @@ "scope": "flutter, dart", "prefix": [ "doc-animation", - "dartdoc-animation", "@doc-animation" ], "description": "Add animation to documentation", @@ -244,14 +198,14 @@ "Dart doc new template": { "scope": "flutter, dart", "prefix": [ + "newtmpl", "@template", "template", - "dartdoc-new-template", + "doc-new-template", "doc-new-macro", - "newtmpl", "@doc-template" ], - "description": "Creates a new dartdoc template with current file's name as its prefix", + "description": "Creates a new dartdoc template with current file's name as its prefix.", "body": [ "/// {@template ${1:$TM_FILENAME_BASE}}", "/// ${0:Body of the template}", @@ -261,24 +215,22 @@ "Dart doc use macro": { "scope": "flutter, dart", "prefix": [ + "usetmpl", "@macro", "macro", - "dartdoc-use-template", + "doc-use-template", "doc-use-macro", - "usetmpl", "@doc-macro" ], - "description": "Uses existing dartdoc macro with current file's name as its prefix", + "description": "Uses existing dartdoc macro with current file's name as its prefix.", "body": "/// {@macro ${0:$TM_FILENAME_BASE}}" }, "Dart doc inject html": { "scope": "flutter, dart", "prefix": [ + "doc-html", "@inject-html", "inject-html", - "dartdoc-html", - "doc-html", - "html", "@doc-html" ], "description": "Injects html into the current comment", @@ -291,17 +243,17 @@ "Deprecated": { "scope": "flutter, dart", "prefix": [ - "@deprecated", - "deprecated" + "deprecated", + "@deprecated" ], - "description": "Deprecated", + "description": "Create a new deprecated annotation. Used to mark a class, method, or property as deprecated.", "body": "@Deprecated('${0:Reason}')" }, "Meta": { "scope": "flutter, dart", "prefix": [ - "@meta", "meta", + "@meta", "@annotation", "annotation" ], diff --git a/snippets/flutter.json b/snippets/flutter.json index 660564b..65d8bde 100644 --- a/snippets/flutter.json +++ b/snippets/flutter.json @@ -330,7 +330,7 @@ "stateOf": { "scope": "flutter, dart", "prefix": "stateOf", - "description": "StatefulWidget.of(BuildContext)", + "description": "Create a new static `of` method for an InheritedWidget. Returns the nearest widget of the given type T and creates a dependency on it, or null if no appropriate widget is found.", "body": [ "/// The state from the closest instance of this class", "/// that encloses the given context, if any.", @@ -354,7 +354,7 @@ "widgetOf": { "scope": "flutter, dart", "prefix": "widgetOf", - "description": "StatelessWidget.of(BuildContext)", + "description": "Create a new static `widgetOf` method for an Widget object. Returns the nearest ancestor widget of the given type T, which must be the type of a concrete Widget subclass.", "body": [ "/// The state from the closest instance of this class", "/// that encloses the given context, if any.", @@ -627,7 +627,10 @@ }, "Stateful Builder": { "scope": "flutter, dart", - "prefix": "statefulBuilder", + "prefix": [ + "stfBuilder", + "statefulBuilder" + ], "description": "Creates a widget that both has state and delegates its build to a callback. Useful for rebuilding specific sections of the widget tree.", "body": [ "StatefulBuilder(", @@ -638,7 +641,10 @@ }, "Stream Builder": { "scope": "flutter, dart", - "prefix": "streamBuilder", + "prefix": [ + "strBuilder", + "streamBuilder" + ], "description": "Creates a new `StreamBuilder` that builds itself based on the latest snapshot of interaction with the specified `stream`", "body": [ "StreamBuilder<${1:int}>(", @@ -649,37 +655,59 @@ ")," ] }, - "Value Listenable Builder": { + "Animated Builder": { "scope": "flutter, dart", - "prefix": "valueListenableBuilder", - "description": "Given a ValueListenable and a builder which builds widgets from concrete values of T, this class will automatically register itself as a listener of the ValueListenable and call the builder with updated values when the value changes.", + "prefix": [ + "animBuilder", + "animatedBuilder" + ], + "description": "Creates an Animated Builder. The widget specified to `child` is passed to the `builder`", "body": [ - "ValueListenableBuilder<${1:int}>(", - " valueListenable: ${2: null},", - " builder: (context, value, child) =>", + "AnimatedBuilder(", + " animation: ${1:animation},", + " builder: (context, child) =>", " ${0:const Placeholder()},", " child: ${2:child},", ")," ] }, - "Animated Builder": { + "Listenable Builder": { "scope": "flutter, dart", - "prefix": "animatedBldr", - "description": "Creates an Animated Builder. The widget specified to `child` is passed to the `builder`", + "prefix": [ + "lisBuilder", + "listenableBuilder" + ], + "description": "A widget that builds itself based on the latest value of a Listenable it listens to.", "body": [ - "AnimatedBuilder(", - " animation: ${1:animation},", + "ListenableBuilder(", + " listenable: ${1: null},", " builder: (context, child) =>", " ${0:const Placeholder()},", " child: ${2:child},", ")," ] }, + "Value Listenable Builder": { + "scope": "flutter, dart", + "prefix": [ + "valLisBuilder", + "valueListenableBuilder" + ], + "description": "Given a ValueListenable and a builder which builds widgets from concrete values of T, this class will automatically register itself as a listener of the ValueListenable and call the builder with updated values when the value changes.", + "body": [ + "ValueListenableBuilder<${1:int}>(", + " valueListenable: ${2: null},", + " builder: (context, value, child) =>", + " ${0:const Placeholder()},", + " child: ${2:child},", + ")," + ] + }, "Animated Switcher": { "scope": "flutter, dart", "prefix": [ - "animatedSwitcher", - "switcher" + "switcher", + "animatedSwitcher" ], "description": "Creates an Animated Switcher.", "body": [ @@ -691,7 +719,10 @@ }, "Orientation Builder": { "scope": "flutter, dart", - "prefix": "orientationBuilder", + "prefix": [ + "orientBuilder", + "orientationBuilder" + ], "description": "Creates a builder which allows for the orientation of the device to be specified and referenced", "body": [ "OrientationBuilder(", @@ -703,7 +734,10 @@ }, "Layout Builder": { "scope": "flutter, dart", - "prefix": "layoutBuilder", + "prefix": [ + "layBuilder", + "layoutBuilder" + ], "description": "Similar to the Builder widget except that the framework calls the builder function at layout time and provides the parent widget's constraints.", "body": [ "LayoutBuilder(", @@ -715,7 +749,10 @@ }, "Repaint boundary": { "scope": "flutter, dart", - "prefix": "repaintBoundary", + "prefix": [ + "repBound", + "repaintBoundary" + ], "description": "Creates a widget that isolates repaints.", "body": [ "RepaintBoundary(", @@ -739,7 +776,10 @@ }, "Future Builder": { "scope": "flutter, dart", - "prefix": "futureBldr", + "prefix": [ + "futBuilder", + "futureBuilder" + ], "body": [ "FutureBuilder(", " future: ${1:Future},", @@ -753,7 +793,10 @@ }, "Tween Animation Builder": { "scope": "flutter, dart", - "prefix": "tweenAnimationBuilder", + "prefix": [ + "tweenAnimBuilder", + "tweenAnimationBuilder" + ], "description": "Widget builder that animates a property of a Widget to a target value whenever the target value changes.", "body": [ "TweenAnimationBuilder<${3:Object?}>(", diff --git a/snippets/markdown.json b/snippets/markdown.json new file mode 100644 index 0000000..5e45357 --- /dev/null +++ b/snippets/markdown.json @@ -0,0 +1,44 @@ +{ + "Changelog unreleased": { + "scope": "md, markdown", + "prefix": [ + "unreleased", + "changelog_unreleased" + ], + "description": "Changelog unreleased", + "body": [ + "## Unreleased", + "", + "- **ADDED**: ${0}", + "- **CHANGED**: ", + "- **DEPRECATED**: ", + "- **REMOVED**: ", + "- **FIXED**: ", + "- **SECURITY**: ", + "- **REFACTOR**: ", + "- **DOCS**: ", + " " + ] + }, + "Changelog version": { + "scope": "md, markdown", + "prefix": [ + "version", + "changelog_version" + ], + "description": "Changelog version section", + "body": [ + "## ${1:0}.${2:0}.${3:0}", + "", + "- **ADDED**: ${0}", + "- **CHANGED**: ", + "- **DEPRECATED**: ", + "- **REMOVED**: ", + "- **FIXED**: ", + "- **SECURITY**: ", + "- **REFACTOR**: ", + "- **DOCS**: ", + " " + ] + } +} \ No newline at end of file From 9c7422cc3350d917ef7137e0c842b7ec39a00104 Mon Sep 17 00:00:00 2001 From: Plague Fox Date: Thu, 22 Aug 2024 15:39:20 +0400 Subject: [PATCH 2/5] Improve dart descriptions --- README.md | 46 ++++++++++++++++++++++----------------------- snippets/dart.json | 47 +++++++++++++++++++++++----------------------- 2 files changed, 47 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index d896ea2..b191626 100644 --- a/README.md +++ b/README.md @@ -14,29 +14,29 @@ Extension add some useful commands to Flutter development in Visual Studio Code. | Shortcut | Description | | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| main | Create a new main function. The entry point of a Dart app. | -| try | Create a new try-catch block. Used to handle exceptions. | -| timeout | Create a new timeout block. Used to handle timeouts. | -| stopwatch | Create a new Stopwatch. Used to measure elapsed time. | -| conditional_imports | Create a new conditional import. Used to import a library based on a current environment (VM or JS) | -| dvd | Divider comment line. Used to separate sections of code. | -| reverseList | Create a new reverse list function. Reverse list traversal in a loop. | -| part | Create a new part directive. Used to specify a URI where part of the library is located. | -| mocks | Import mocks file. Used to import a file with mocks. | -| equals | Hash code and equals methods. Used to override the `==` operator and the `hashCode` getter. | -| nosm | Create a new noSuchMethod method. Used to implement the `noSuchMethod` method. | -| test | Create a new test function. Used to define a test case. | -| pragma | Create a new pragma directive. Used to specify options that affect the behavior of the Dart compiler. | -| doc-disabled | Create a new disabled documentation comment. Used to disable a block of documentation comments. | -| doc-category | Create a new category documentation comment. Used to categorize a block of documentation comments. | -| doc-image | Create a new image documentation comment. Used to add an image to a block of documentation comments. | -| doc-animation | Create a new animation documentation comment. Used to add an animation to a block of documentation comments. | -| doc-html | Create a new HTML documentation comment. Used to add HTML to a block of documentation comments. | -| newtmpl | Creates a new dartdoc template with current file's name as its prefix. | -| usetmpl | Uses existing dartdoc macro with current file's name as its prefix. | -| deprecated | Create a new deprecated annotation. Used to mark a class, method, or property as deprecated. | -| meta | Create a new meta annotation. Used to annotate a class, method, or property with metadata. | -| coverage | Create a comment line for coverage. Used to mark a line or block of code that is not covered by tests. | +| main | Generates a main function with error handling and zone management for Dart applications. | +| try | Creates a try-catch-finally block, useful for managing exceptions and ensuring cleanup code runs. | +| timeout | Creates a timeout handler for setting execution limits on asynchronous operations. | +| stopwatch | Initializes a Stopwatch to measure and log elapsed time for code execution. | +| conditional | Generates platform-specific imports based on the environment (VM or JS), ensuring compatibility across different platforms. | +| dvd | Inserts a divider comment line, useful for visually separating sections of code. | +| reverseList | Generates a loop for traversing a list in reverse order. | +| part | Adds a part directive to include the specified Dart file as part of the current library. | +| mocks | Imports a Dart file containing mock implementations for testing purposes. | +| equals | Generates hash code and equals methods, overriding the `==` operator and the `hashCode` getter for custom object comparison. | +| nosm | Implements the `noSuchMethod` method, handling calls to non-existent methods or properties. | +| test | Creates a test function, setting up a basic test case using the `test` package. | +| pragma | Inserts a pragma directive to optimize or modify Dart VM/compiler behavior based on the specified options. | +| doc-disabled | Adds a comment annotation to disable documentation generation for the specified block of code. | +| doc-category | Categorizes a block of documentation with the specified category or subcategory tags. | +| doc-image | Embeds an image within a block of documentation, using the specified URL as the source. | +| doc-animation | Embeds an animation within a block of documentation, with options for specifying the size and source URL. | +| doc-html | Injects custom HTML into a documentation comment, allowing for rich formatting or content inclusion. | +| newtmpl | Creates a new Dart documentation template with the current file's name as the prefix, useful for reusing content across multiple documentation blocks. | +| usetmpl | Inserts an existing Dart documentation macro, using the current file's name as the prefix, to maintain consistency in documentation. | +| deprecated | Marks a class, method, or property as deprecated, indicating that it should no longer be used and may be removed in future versions. | +| meta | Applies a meta annotation to a class, method, or property, providing additional metadata for tooling or code analysis purposes. | +| coverage | Adds a coverage annotation to mark lines or blocks of code that should be ignored by test coverage tools. | ## Flutter snippets diff --git a/snippets/dart.json b/snippets/dart.json index 901534a..50d3a8a 100644 --- a/snippets/dart.json +++ b/snippets/dart.json @@ -2,7 +2,7 @@ "Main entry point": { "scope": "flutter, dart", "prefix": "main", - "description": "Main entry point.", + "description": "Generates a main function with error handling and zone management for Dart applications.", "body": [ "import 'dart:async';\n", "@pragma('vm:entry-point')", @@ -17,7 +17,7 @@ "Try-catch-finally block": { "scope": "flutter, dart", "prefix": "try", - "description": "Try-catch-finally block.", + "description": "Creates a try-catch-finally block, useful for managing exceptions and ensuring cleanup code runs.", "body": [ "try {", " // ...", @@ -31,13 +31,13 @@ "Timeout handler": { "scope": "flutter, dart", "prefix": "timeout", - "description": "Timeout handler.", + "description": "Creates a timeout handler for setting execution limits on asynchronous operations.", "body": "timeout(const Duration(milliseconds: 5000))${0:;}" }, "Stopwatch": { "scope": "flutter, dart", "prefix": "stopwatch", - "description": "Stopwatch. Used to measure elapsed time.", + "description": "Initializes a Stopwatch to measure and log elapsed time for code execution.", "body": [ "final stopwatch = Stopwatch()..start();", "try {", @@ -54,10 +54,11 @@ "Platform conditional imports": { "scope": "flutter, dart", "prefix": [ + "conditional", "conditional_imports", "import_conditional" ], - "description": "Platform conditional imports", + "description": "Generates platform-specific imports based on the environment (VM or JS), ensuring compatibility across different platforms.", "body": [ "import 'stub.dart'", " // ignore: uri_does_not_exist", @@ -72,7 +73,7 @@ "dvd", "divider_comment" ], - "description": "Divider comment line. Used to separate sections of code.", + "description": "Inserts a divider comment line, useful for visually separating sections of code.", "body": "// --- ${1} --- //\n\n$0" }, "Reverse bypass": { @@ -80,7 +81,7 @@ "prefix": [ "reverseList" ], - "description": "Reverse list traversal in a loop", + "description": "Generates a loop for traversing a list in reverse order.", "body": [ "for (var i = list.length - 1; i >= 0; i--) $0" ] @@ -88,7 +89,7 @@ "Part": { "scope": "flutter, dart", "prefix": "part", - "description": "Part of file", + "description": "Adds a part directive to include the specified Dart file as part of the current library.", "body": [ "part '${TM_FILENAME_BASE}.g.dart';$0" ] @@ -96,7 +97,7 @@ "Mocks": { "scope": "flutter, dart", "prefix": "mocks", - "description": "Import mocks file", + "description": "Imports a Dart file containing mock implementations for testing purposes.", "body": [ "import '${TM_FILENAME_BASE}.mocks.dart';$0" ] @@ -108,7 +109,7 @@ "equals", "==" ], - "description": "Hash Code and Equals override", + "description": "Generates hash code and equals methods, overriding the `==` operator and the `hashCode` getter for custom object comparison.", "body": [ "@override", "int get hashCode => id.hashCode;\n", @@ -125,7 +126,7 @@ "nosm", "noSuchMethod" ], - "description": "This method is invoked when a non-existent method or property is accessed.", + "description": "Implements the `noSuchMethod` method, handling calls to non-existent methods or properties.", "body": [ "@override", "dynamic noSuchMethod(Invocation invocation) {", @@ -139,7 +140,7 @@ "test", "unitTest" ], - "description": "Create a test function", + "description": "Creates a test function, setting up a basic test case using the `test` package.", "body": [ "test('${1:test description}', () {", " ${0:expect(true, isTrue);}", @@ -152,7 +153,7 @@ "pragma", "@pragma" ], - "description": "Pragma annotation https://mrale.ph/dartvm/pragmas.html", + "description": "Inserts a pragma directive to optimize or modify Dart VM/compiler behavior based on the specified options.", "body": "@pragma(${1|'vm:entry-point','vm:never-inline','vm:prefer-inline','dart2js:tryInline','vm:notify-debugger-on-exception','vm:invisible','vm:always-consider-inlining','flutter:keep-to-string','flutter:keep-to-string-in-subtypes'|})" }, "Dart doc disable documentation": { @@ -161,7 +162,7 @@ "doc-disabled", "@doc-disabled" ], - "description": "No documentation annotation", + "description": "Adds a comment annotation to disable documentation generation for the specified block of code.", "body": [] }, "Dart doc category": { @@ -170,7 +171,7 @@ "doc-category", "@doc-category" ], - "description": "Add category to documentation", + "description": "Categorizes a block of documentation with the specified category or subcategory tags.", "body": [ "/// {@${1|category,subCategory|} ${0}}" ] @@ -181,7 +182,7 @@ "doc-image", "@doc-image" ], - "description": "Add image to documentation", + "description": "Embeds an image within a block of documentation, using the specified URL as the source.", "body": [ "/// {@image }" ] @@ -192,7 +193,7 @@ "doc-animation", "@doc-animation" ], - "description": "Add animation to documentation", + "description": "Embeds an animation within a block of documentation, with options for specifying the size and source URL.", "body": "/// {@animation name 100 200 ${0:https://host.tld/path/to/video.mp4}}" }, "Dart doc new template": { @@ -205,7 +206,7 @@ "doc-new-macro", "@doc-template" ], - "description": "Creates a new dartdoc template with current file's name as its prefix.", + "description": "Creates a new Dart documentation template with the current file's name as the prefix, useful for reusing content across multiple documentation blocks.", "body": [ "/// {@template ${1:$TM_FILENAME_BASE}}", "/// ${0:Body of the template}", @@ -222,7 +223,7 @@ "doc-use-macro", "@doc-macro" ], - "description": "Uses existing dartdoc macro with current file's name as its prefix.", + "description": "Inserts an existing Dart documentation macro, using the current file's name as the prefix, to maintain consistency in documentation.", "body": "/// {@macro ${0:$TM_FILENAME_BASE}}" }, "Dart doc inject html": { @@ -233,7 +234,7 @@ "inject-html", "@doc-html" ], - "description": "Injects html into the current comment", + "description": "Injects custom HTML into a documentation comment, allowing for rich formatting or content inclusion.", "body": [ "/// {@inject-html}", "/// ${0:

[The HTML to inject.]()

}", @@ -246,7 +247,7 @@ "deprecated", "@deprecated" ], - "description": "Create a new deprecated annotation. Used to mark a class, method, or property as deprecated.", + "description": "Marks a class, method, or property as deprecated, indicating that it should no longer be used and may be removed in future versions.", "body": "@Deprecated('${0:Reason}')" }, "Meta": { @@ -257,7 +258,7 @@ "@annotation", "annotation" ], - "description": "Meta annotation", + "description": "Applies a meta annotation to a class, method, or property, providing additional metadata for tooling or code analysis purposes.", "body": "@${1|immutable,useResult,internal,protected,literal,mustCallSuper,sealed,alwaysThrows,factory,visibleForOverriding,visibleForTesting,experimental,nonVirtual,doNotStore,optionalTypeArgs|}" }, "Coverage": { @@ -265,7 +266,7 @@ "prefix": [ "coverage" ], - "description": "Coverage annotation", + "description": "Adds a coverage annotation to mark lines or blocks of code that should be ignored by test coverage tools.", "body": "// coverage:${1|ignore-line,ignore-start,ignore-end,ignore-file|}" } } \ No newline at end of file From b34b35de75de65b8755143969379ce427a4dae65 Mon Sep 17 00:00:00 2001 From: Plague Fox Date: Thu, 22 Aug 2024 15:49:49 +0400 Subject: [PATCH 3/5] chore: Improve readability and maintainability of GitHub Actions workflow files --- README.md | 82 +++++++++++++++++++-------------------- snippets/flutter.json | 90 +++++++++++++++++++++---------------------- 2 files changed, 86 insertions(+), 86 deletions(-) diff --git a/README.md b/README.md index b191626..dcaa946 100644 --- a/README.md +++ b/README.md @@ -43,44 +43,44 @@ Extension add some useful commands to Flutter development in Visual Studio Code. | Shortcut | Description | | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| mateapp | Create a new MaterialApp widget. An application that uses Material Design. | -| cupeapp | Create a new CupertinoApp widget. An application that uses Cupertino design. | -| scaffold | Create a new Scaffold widget. Implements the basic Material Design visual layout structure. | -| stl | Create a new StatelessWidget. A widget that does not require mutable state. | -| stlChild | Create a new StatelessWidget with a child. A widget that does not require mutable state. | -| stf | Create a new StatefulWidget. A widget that has mutable state. | -| stfChild | Create a new StatefulWidget with a child. A widget that has mutable state. | -| inh | Create a new InheritedWidget. Base class for widgets that efficiently propagate information down the tree. | -| of | Create a new static `of` method for an InheritedWidget. Returns the nearest widget of the given type T and creates a dependency on it, or null if no appropriate widget is found. | -| stateOf | Create a new static `stateOf` method for an State object. Returns the State object of the nearest ancestor StatefulWidget widget that is an instance of the given type T. | -| widgetOf | Create a new static `widgetOf` method for an Widget object. Returns the nearest ancestor widget of the given type T, which must be the type of a concrete Widget subclass. | -| painter | Create a new CustomPainter. A widget that provides a canvas on which to draw during the paint phase. Used for drawing custom shapes. | -| clipper | Create a new CustomClipper. Used for creating custom shapes. | -| debugFillProperties | Create a new debugFillProperties method. Add additional properties associated with the node. | -| initS | Create a new initState method. Called when this object is inserted into the tree. The framework will call this method exactly once for each State object it creates. | -| dispose | Create a new dispose method. Called when this object is removed from the tree permanently. The framework calls this method when this State object will never build again. | -| reassemble | Create a new reassemble method. Called whenever the application is reassembled during debugging, for example during hot reload. | -| didChangeD | Create a new didChangeDependencies method. Called when a dependency of this element changes. | -| didUpdateW | Create a new didUpdateWidget method. Called whenever the widget configuration changes. | -| build | Create a new build method. Describes the part of the user interface represented by this widget. | -| listViewBuilder | Create a new ListView.builder. A scrollable list that works with a list of children. | -| listViewSeparated | Create a new ListView.separated. A scrollable list that works with a list of children separated by a divider. | -| gridViewBuilder | Create a new GridView.builder. A scrollable, 2D array of widgets. | -| gridViewCount | Create a new GridView.count. A scrollable, 2D array of widgets with a fixed number of tiles in the cross axis. | -| gridViewE | Create a new GridView.extent. A scrollable, 2D array of widgets with a maximum number of tiles in the cross axis. | -| customScrollV | Create a new CustomScrollView. A ScrollView that creates custom scroll effects using slivers. | -| builder | Create a new Builder. A widget that delegates its building to a callback. | -| wrapWithBuilder | Wrap the selected widget with a Builder. A widget that delegates its building to a callback. | -| stfBuilder | Create a new StatefulWidget with a Builder. A widget that has mutable state and delegates its building to a callback. | -| strBuilder | Create a new StreamBuilder. A widget that builds itself based on the latest snapshot of interaction with a Stream. | -| lisBuilder | Create a new ListenableBuilder. A widget that builds itself based on the latest value of a Listenable it listens to. | -| valLisBuilder | Create a new ValueListenableBuilder. A widget that builds itself based on the latest value of a ValueListenable it listens to. | -| animBuilder | Create a new AnimatedBuilder. A general-purpose widget for building animations. | -| switcher | Create a new AnimatedSwitcher. A widget that switches between two children and animates the transition. | -| orientBuilder | Create a new OrientationBuilder. A widget that builds itself based on the latest orientation of the device. | -| layBuilder | Create a new LayoutBuilder. A widget that builds itself based on the latest layout constraints. | -| repBound | Create a new RepaintBoundary. A widget that isolates repaints, so that a repaint of one child is separate from other children. | -| singleChildSV | Create a new SingleChildScrollView. A box in which a single widget can be scrolled. | -| futBuilder | Create a new FutureBuilder. A widget that builds itself based on the latest snapshot of interaction with a Future. | -| tweenAnimBuilder | Create a new TweenAnimationBuilder. An animation that interpolates between two animatable objects. | -| testWidget | Create a new testWidgets function for testing a widget. | \ No newline at end of file +| mateapp | Creates a new `MaterialApp` widget, an application that uses Material Design components and theming. | +| cupeapp | Creates a new `CupertinoApp` widget, an application that uses Cupertino (iOS-style) design components and theming. | +| scaffold | Creates a new `Scaffold` widget, implementing the basic Material Design visual layout structure including app bar, drawer, and floating action button. | +| stl | Generates a new `StatelessWidget` class, a widget that does not require mutable state and is rebuilt only when the configuration changes. | +| stlChild | Generates a new `StatelessWidget` class with a child widget, for cases where a single child widget needs to be passed and rendered. | +| stf | Generates a new `StatefulWidget` class, a widget that has mutable state that can change over time, and its associated `State` class. | +| stfChild | Generates a new `StatefulWidget` class with a child widget, allowing for a stateful widget to have a single child widget passed in and managed. | +| inh | Creates a new `InheritedWidget` class, which efficiently propagates information down the widget tree to descendants. | +| of | Generates a static `of` method for an `InheritedWidget`, returning the nearest widget of the specified type and creating a dependency on it. | +| stateOf | Generates a static `stateOf` method for a `State` object, returning the `State` object of the nearest ancestor `StatefulWidget` of the specified type. | +| widgetOf | Generates a static `widgetOf` method for a `Widget` object, returning the nearest ancestor widget of the specified type. | +| painter | Creates a new `CustomPainter` class, which provides a canvas on which to draw during the paint phase, used for drawing custom shapes and graphics. | +| clipper | Creates a new `CustomClipper` class, used for defining custom clipping shapes for widgets. | +| debugFillProperties | Generates a `debugFillProperties` method to add additional properties associated with the widget for debugging purposes. | +| initS | Creates an `initState` method, called when this object is inserted into the widget tree for the first time, typically used to initialize state. | +| dispose | Creates a `dispose` method, called when this object is permanently removed from the widget tree, used for cleanup of resources. | +| reassemble | Creates a `reassemble` method, called during debugging whenever the application is reassembled, for example, during a hot reload. | +| didChangeD | Creates a `didChangeDependencies` method, called when a dependency of the `State` object changes. | +| didUpdateW | Creates a `didUpdateWidget` method, called whenever the widget’s configuration changes. | +| build | Generates a `build` method, describing the part of the user interface represented by this widget. | +| listViewBuilder | Creates a `ListView.builder`, a scrollable list that lazily builds its children as they scroll into view, useful for large or infinite lists. | +| listViewSeparated | Creates a `ListView.separated`, a scrollable list that displays a separator widget between each child widget, ideal for lists with visually distinct sections. | +| gridViewBuilder | Creates a `GridView.builder`, a scrollable grid of widgets that are created on demand. | +| gridViewCount | Creates a `GridView.count`, a scrollable grid of widgets with a fixed number of tiles in the cross axis. | +| gridViewE | Creates a `GridView.extent`, a scrollable grid of widgets with tiles that each have a maximum cross-axis extent. | +| customScrollV | Creates a `CustomScrollView`, a scrollable area that creates custom scroll effects using slivers. | +| builder | Creates a `Builder` widget, which allows you to create a child widget in a way that depends on the `BuildContext`. | +| wrapWithBuilder | Wraps the selected widget with a `Builder` widget, delegating the widget building process to a callback. | +| stfBuilder | Creates a `StatefulBuilder` widget, which allows for state management and rebuilding a specific portion of the widget tree. | +| strBuilder | Creates a `StreamBuilder` widget, which rebuilds itself based on the latest snapshot of interaction with a `Stream`. | +| lisBuilder | Creates a `ListenableBuilder` widget, which rebuilds itself based on the latest value of a `Listenable` it listens to. | +| valLisBuilder | Creates a `ValueListenableBuilder` widget, which rebuilds itself based on the latest value of a `ValueListenable`. | +| animBuilder | Creates an `AnimatedBuilder` widget, which rebuilds itself based on an animation. | +| switcher | Creates an `AnimatedSwitcher` widget, which switches between two children and animates the transition between them. | +| orientBuilder | Creates an `OrientationBuilder` widget, which rebuilds itself based on the latest orientation of the device (portrait or landscape). | +| layBuilder | Creates a `LayoutBuilder` widget, which rebuilds itself based on the latest layout constraints, useful for responsive layouts. | +| repBound | Creates a `RepaintBoundary` widget, which isolates repaints so that a repaint of one child is separate from others, improving performance. | +| singleChildSV | Creates a `SingleChildScrollView` widget, which allows a single child to be scrolled. | +| futBuilder | Creates a `FutureBuilder` widget, which rebuilds itself based on the latest snapshot of interaction with a `Future`. | +| tweenAnimBuilder | Creates a `TweenAnimationBuilder` widget, which animates a property of a widget to a target value whenever the target value changes. | +| testWidget | Creates a `testWidgets` function for testing a widget, typically used in Flutter's unit testing framework. | diff --git a/snippets/flutter.json b/snippets/flutter.json index 65d8bde..fcc1cd4 100644 --- a/snippets/flutter.json +++ b/snippets/flutter.json @@ -2,7 +2,7 @@ "Material App": { "scope": "flutter, dart", "prefix": "mateapp", - "description": "Create a MaterialApp", + "description": "Creates a MaterialApp widget, a base application structure using Material Design components.", "body": [ "import 'dart:async';\n", "import 'package:flutter/material.dart';\n", @@ -36,7 +36,7 @@ "Cupertino App": { "scope": "flutter, dart", "prefix": "cupeapp", - "description": "Create a CupertinoApp", + "description": "Creates a CupertinoApp widget, a base application structure using Cupertino (iOS-style) design components.", "body": [ "import 'dart:async';\n", "import 'package:flutter/cupertino.dart';\n\n", @@ -70,7 +70,7 @@ "Scaffold": { "scope": "flutter, dart", "prefix": "scaffold", - "description": "Create a Scaffold", + "description": "Creates a Scaffold widget, the basic structure for Material Design visual layout.", "body": [ "Scaffold(", " appBar: AppBar(", @@ -90,7 +90,7 @@ "stl", "statelessWidget" ], - "description": "Snippet for Stateless Widget", + "description": "Generates a new StatelessWidget class.", "body": [ "import 'package:flutter/widgets.dart';\n\n", "/// {@template ${2:$TM_FILENAME_BASE}}", @@ -114,7 +114,7 @@ "stlChild", "statelessWidgetWithChild" ], - "description": "Snippet for Stateless Widget with child", + "description": "Generates a new StatelessWidget class with a child widget.", "body": [ "import 'package:flutter/widgets.dart';\n\n", "/// {@template ${2:$TM_FILENAME_BASE}}", @@ -142,7 +142,7 @@ "stf", "statefulWidget" ], - "description": "Snippet for Stateful Widget", + "description": "Generates a new StatefulWidget class.", "body": [ "import 'package:flutter/widgets.dart';", "import 'package:meta/meta.dart';\n\n", @@ -207,7 +207,7 @@ "stfChild", "statefulfWithChild" ], - "description": "Snippet for Stateful Widget with child", + "description": "Generates a new StatefulWidget class with a child widget.", "body": [ "import 'package:flutter/widgets.dart';", "import 'package:meta/meta.dart';\n\n", @@ -279,7 +279,7 @@ "inh", "inheritedWidget" ], - "description": "Inherited Widget", + "description": "Generates an InheritedWidget class.", "body": [ "import 'package:flutter/widgets.dart';\n\n", "/// {@template ${2:$TM_FILENAME_BASE}}", @@ -304,7 +304,7 @@ "of", "maybeOf" ], - "description": "InheritedWidget.of(BuildContext)", + "description": "Creates a static `of` method for an InheritedWidget.", "body": [ "/// The state from the closest instance of this class", "/// that encloses the given context, if any.", @@ -330,7 +330,7 @@ "stateOf": { "scope": "flutter, dart", "prefix": "stateOf", - "description": "Create a new static `of` method for an InheritedWidget. Returns the nearest widget of the given type T and creates a dependency on it, or null if no appropriate widget is found.", + "description": "Creates a static `stateOf` method for a State object.", "body": [ "/// The state from the closest instance of this class", "/// that encloses the given context, if any.", @@ -354,7 +354,7 @@ "widgetOf": { "scope": "flutter, dart", "prefix": "widgetOf", - "description": "Create a new static `widgetOf` method for an Widget object. Returns the nearest ancestor widget of the given type T, which must be the type of a concrete Widget subclass.", + "description": "Creates a static `widgetOf` method for a Widget object.", "body": [ "/// The state from the closest instance of this class", "/// that encloses the given context, if any.", @@ -378,7 +378,7 @@ "Build Method": { "scope": "flutter, dart", "prefix": "build", - "description": "Describes the part of the user interface represented by this widget.", + "description": "Creates a `build` method, describing the part of the UI represented by this widget.", "body": [ "@override", "Widget build(BuildContext context) =>", @@ -391,7 +391,7 @@ "painter", "customPainter" ], - "description": "Used for creating custom paint", + "description": "Creates a CustomPainter class for custom drawing.", "body": [ "/// {@template ${2:$TM_FILENAME_BASE}}", "/// ${1:${TM_FILENAME_BASE/(.)(.*)/${1:/upcase}${2:/camelcase}/}}Painter.", @@ -419,10 +419,10 @@ "clipper", "customClipper" ], - "description": "Used for creating custom shapes", + "description": "Creates a CustomClipper class for defining custom clipping shapes.", "body": [ "/// {@template ${2:$TM_FILENAME_BASE}}", - "/// ${1:${TM_FILENAME_BASE/(.)(.*)/${1:/upcase}${2:/camelcase}/}}Painter.", + "/// ${1:${TM_FILENAME_BASE/(.)(.*)/${1:/upcase}${2:/camelcase}/}}Clipper.", "/// {@endtemplate}", "class ${1}Clipper extends CustomClipper {", " /// {@macro ${2}}", @@ -441,7 +441,7 @@ "debugFillProperties": { "scope": "flutter, dart", "prefix": "debugFillProperties", - "description": "debugFillProperties", + "description": "Creates a `debugFillProperties` method for adding debug properties.", "body": [ "@override", "void debugFillProperties(DiagnosticPropertiesBuilder properties) =>", @@ -460,7 +460,7 @@ "initState": { "scope": "flutter, dart", "prefix": "initS", - "description": "Called when this object is inserted into the tree. The framework will call this method exactly once for each State object it creates.", + "description": "Creates an `initState` method, initializing state when the widget is inserted into the tree.", "body": [ "@override", "void initState() {", @@ -472,19 +472,19 @@ "dispose": { "scope": "flutter, dart", "prefix": "dispose", + "description": "Creates a `dispose` method, cleaning up resources when the widget is removed from the tree.", "body": [ "@override", "void dispose() {", " ${0:}", " super.dispose();", "}" - ], - "description": "Called when this object is removed from the tree permanently. The framework calls this method when this State object will never build again." + ] }, "reassemble": { "scope": "flutter, dart", "prefix": "reassemble", - "description": "Called whenever the application is reassembled during debugging, for example during hot reload.", + "description": "Creates a `reassemble` method, called during hot reload.", "body": [ "@override", "void reassemble(){", @@ -496,7 +496,7 @@ "didChangeDependencies": { "scope": "flutter, dart", "prefix": "didChangeD", - "description": "Called when a dependency of this State object changes", + "description": "Creates a `didChangeDependencies` method, called when a dependency of this `State` object changes.", "body": [ "@override", "void didChangeDependencies() {", @@ -508,7 +508,7 @@ "didUpdateWidget": { "scope": "flutter, dart", "prefix": "didUpdateW", - "description": "Called whenever the widget configuration changes.", + "description": "Creates a `didUpdateWidget` method, called when the widget’s configuration changes.", "body": [ "@override", "void didUpdateWidget (covariant ${1:Type} ${2:oldWidget}) {", @@ -520,7 +520,7 @@ "ListView.builder": { "scope": "flutter, dart", "prefix": "listViewBuilder", - "description": "Creates a scrollable, linear array of widgets that are created on demand.Providing a non-null `itemCount` improves the ability of the [ListView] to estimate the maximum scroll extent.", + "description": "Creates a `ListView.builder`, a scrollable list that lazily builds its children as they scroll into view.", "body": [ "ListView.builder(", " itemCount: ${1:1},", @@ -532,7 +532,7 @@ "ListView.separated": { "scope": "flutter, dart", "prefix": "listViewSeparated", - "description": "Creates a fixed-length scrollable linear array of list 'items' separated by list item 'separators'.", + "description": "Creates a `ListView.separated`, a scrollable list with separators between items.", "body": [ "ListView.separated(", " itemCount: ${1:1},", @@ -548,7 +548,7 @@ "GridView.builder": { "scope": "flutter, dart", "prefix": "gridViewBuilder", - "description": "Creates a scrollable, 2D array of widgets that are created on demand. Providing a non-null `itemCount` improves the ability of the [GridView] to estimate the maximum scroll extent.", + "description": "Creates a `GridView.builder`, a scrollable grid of widgets that are created on demand.", "body": [ "GridView.builder(", " gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(", @@ -564,7 +564,7 @@ "GridView.count": { "scope": "flutter, dart", "prefix": "gridViewCount", - "description": "Creates a scrollable, 2D array of widgets with a fixed number of tiles in the cross axis.", + "description": "Creates a `GridView.count`, a scrollable grid of widgets with a fixed number of tiles in the cross axis.", "body": [ "GridView.count(", " crossAxisSpacing: ${1:1},", @@ -579,7 +579,7 @@ "GridView.extent": { "scope": "flutter, dart", "prefix": "gridViewE", - "description": "Creates a scrollable, 2D array of widgets with tiles that each have a maximum cross-axis extent.", + "description": "Creates a `GridView.extent`, a scrollable grid of widgets with tiles that each have a maximum cross-axis extent.", "body": [ "GridView.extent(", " maxCrossAxisExtent: ${1:2},", @@ -592,7 +592,7 @@ "Custom Scroll View": { "scope": "flutter, dart", "prefix": "customScrollV", - "description": "Creates a `ScrollView` that creates custom scroll effects using slivers. If the `primary` argument is true, the `controller` must be null.", + "description": "Creates a `CustomScrollView`, a scrollable area that creates custom scroll effects using slivers.", "body": [ "CustomScrollView(", " slivers: [", @@ -604,7 +604,7 @@ "Builder": { "scope": "flutter, dart", "prefix": "builder", - "description": "Creates a widget that delegates its build to a callback.", + "description": "Creates a `Builder` widget, delegating the widget building process to a callback.", "body": [ "Builder(", " builder: (context) =>", @@ -617,7 +617,7 @@ "prefix": [ "wrapWithBuilder" ], - "description": "Wrap a widget with Builder widget.", + "description": "Wraps a widget with a `Builder` widget.", "body": [ "Builder(", " builder: (context) =>", @@ -631,7 +631,7 @@ "stfBuilder", "statefulBuilder" ], - "description": "Creates a widget that both has state and delegates its build to a callback. Useful for rebuilding specific sections of the widget tree.", + "description": "Creates a `StatefulBuilder` widget, allowing for state management and rebuilding a specific portion of the widget tree.", "body": [ "StatefulBuilder(", " builder: (context, setState) =>", @@ -645,7 +645,7 @@ "strBuilder", "streamBuilder" ], - "description": "Creates a new `StreamBuilder` that builds itself based on the latest snapshot of interaction with the specified `stream`", + "description": "Creates a `StreamBuilder` widget, rebuilding itself based on the latest snapshot of interaction with a `Stream`.", "body": [ "StreamBuilder<${1:int}>(", " initialData: ${2:initialData},", @@ -661,7 +661,7 @@ "animBuilder", "animatedBuilder" ], - "description": "Creates an Animated Builder. The widget specified to `child` is passed to the `builder`", + "description": "Creates an `AnimatedBuilder` widget, rebuilding itself based on an animation.", "body": [ "AnimatedBuilder(", " animation: ${1:animation},", @@ -677,7 +677,7 @@ "lisBuilder", "listenableBuilder" ], - "description": "A widget that builds itself based on the latest value of a Listenable it listens to.", + "description": "Creates a `ListenableBuilder` widget, rebuilding itself based on the latest value of a `Listenable` it listens to.", "body": [ "ListenableBuilder(", " listenable: ${1: null},", @@ -693,7 +693,7 @@ "valLisBuilder", "valueListenableBuilder" ], - "description": "Given a ValueListenable and a builder which builds widgets from concrete values of T, this class will automatically register itself as a listener of the ValueListenable and call the builder with updated values when the value changes.", + "description": "Creates a `ValueListenableBuilder` widget, rebuilding itself based on the latest value of a `ValueListenable`.", "body": [ "ValueListenableBuilder<${1:int}>(", " valueListenable: ${2: null},", @@ -709,7 +709,7 @@ "switcher", "animatedSwitcher" ], - "description": "Creates an Animated Switcher.", + "description": "Creates an `AnimatedSwitcher` widget, switching between two children and animating the transition.", "body": [ "AnimatedSwitcher(", " duration: const Duration(milliseconds: 350),", @@ -723,7 +723,7 @@ "orientBuilder", "orientationBuilder" ], - "description": "Creates a builder which allows for the orientation of the device to be specified and referenced", + "description": "Creates an `OrientationBuilder` widget, rebuilding itself based on the latest orientation of the device (portrait or landscape).", "body": [ "OrientationBuilder(", " builder: (context, orientation) {", @@ -738,7 +738,7 @@ "layBuilder", "layoutBuilder" ], - "description": "Similar to the Builder widget except that the framework calls the builder function at layout time and provides the parent widget's constraints.", + "description": "Creates a `LayoutBuilder` widget, rebuilding itself based on the latest layout constraints, useful for responsive layouts.", "body": [ "LayoutBuilder(", " builder: (context, constraints) {", @@ -753,7 +753,7 @@ "repBound", "repaintBoundary" ], - "description": "Creates a widget that isolates repaints.", + "description": "Creates a `RepaintBoundary` widget, isolating repaints to improve performance.", "body": [ "RepaintBoundary(", " key: ValueKey(${1:name}),", @@ -764,6 +764,7 @@ "Single Child ScrollView": { "scope": "flutter, dart", "prefix": "singleChildSV", + "description": "Creates a `SingleChildScrollView` widget, allowing a single child to be scrolled.", "body": [ "SingleChildScrollView(", " controller: ${1:controller,}", @@ -771,8 +772,7 @@ " ${0:}", " ),", ")," - ], - "description": "Creates a scroll view with a single child" + ] }, "Future Builder": { "scope": "flutter, dart", @@ -780,6 +780,7 @@ "futBuilder", "futureBuilder" ], + "description": "Creates a `FutureBuilder` widget, rebuilding itself based on the latest snapshot of interaction with a `Future`.", "body": [ "FutureBuilder(", " future: ${1:Future},", @@ -788,8 +789,7 @@ " return ${3:};", " },", ")," - ], - "description": "Creates a Future Builder. This builds itself based on the latest snapshot of interaction with a Future." + ] }, "Tween Animation Builder": { "scope": "flutter, dart", @@ -797,7 +797,7 @@ "tweenAnimBuilder", "tweenAnimationBuilder" ], - "description": "Widget builder that animates a property of a Widget to a target value whenever the target value changes.", + "description": "Creates a `TweenAnimationBuilder` widget, animating a property of a widget to a target value whenever the target value changes.", "body": [ "TweenAnimationBuilder<${3:Object?}>(", " duration: ${1:const Duration(),}", @@ -813,7 +813,7 @@ "testWidget", "widgetTest" ], - "description": "Create a testWidgets function", + "description": "Creates a `testWidgets` function for testing a widget.", "body": [ "testWidgets(", " \"${1:test description}\",", From 52290a7de7891519f4a732ad56e91dd1c7b911c7 Mon Sep 17 00:00:00 2001 From: Plague Fox Date: Thu, 22 Aug 2024 16:09:40 +0400 Subject: [PATCH 4/5] feat: Add new Flutter layout widgets The code changes include adding new Flutter layout widgets: Row, Column, Wrap, Stack, and FittedBox. These widgets provide flexible options for arranging and positioning child widgets in a Flutter application. This addition enhances the available layout options and improves the overall flexibility and versatility of the application's UI. Note: This commit message follows the established convention of using a "feat" prefix for new feature additions. --- README.md | 6 ++++ snippets/dart.json | 9 +++++ snippets/flutter.json | 78 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) diff --git a/README.md b/README.md index dcaa946..c71d552 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Extension add some useful commands to Flutter development in Visual Studio Code. | reverseList | Generates a loop for traversing a list in reverse order. | | part | Adds a part directive to include the specified Dart file as part of the current library. | | mocks | Imports a Dart file containing mock implementations for testing purposes. | +| toStr | Overrides the `toString` method for a custom object, providing a string representation of the object for debugging or logging. | | equals | Generates hash code and equals methods, overriding the `==` operator and the `hashCode` getter for custom object comparison. | | nosm | Implements the `noSuchMethod` method, handling calls to non-existent methods or properties. | | test | Creates a test function, setting up a basic test case using the `test` package. | @@ -84,3 +85,8 @@ Extension add some useful commands to Flutter development in Visual Studio Code. | futBuilder | Creates a `FutureBuilder` widget, which rebuilds itself based on the latest snapshot of interaction with a `Future`. | | tweenAnimBuilder | Creates a `TweenAnimationBuilder` widget, which animates a property of a widget to a target value whenever the target value changes. | | testWidget | Creates a `testWidgets` function for testing a widget, typically used in Flutter's unit testing framework. | +| row | Creates a `Row` widget, which displays its children in a horizontal array. | +| col | Creates a `Column` widget, which displays its children in a vertical array. | +| wrap | Creates a `Wrap` widget, which displays its children in multiple horizontal or vertical runs, wrapping to the next line when necessary. | +| stack | Creates a `Stack` widget, which allows you to place widgets on top of each other in a z-order. | +| fittedbox | Creates a `FittedBox` widget, which scales and positions its child within itself according to the specified fit. | \ No newline at end of file diff --git a/snippets/dart.json b/snippets/dart.json index 50d3a8a..cbadb29 100644 --- a/snippets/dart.json +++ b/snippets/dart.json @@ -102,6 +102,15 @@ "import '${TM_FILENAME_BASE}.mocks.dart';$0" ] }, + "toString": { + "scope": "flutter, dart", + "prefix": "toStr", + "description": "Overrides the `toString` method for a custom object, providing a string representation of the object for debugging or logging.", + "body": [ + "@override", + "String toString() => '${0}'" + ] + }, "Hash Code": { "scope": "flutter, dart", "prefix": [ diff --git a/snippets/flutter.json b/snippets/flutter.json index fcc1cd4..23c750d 100644 --- a/snippets/flutter.json +++ b/snippets/flutter.json @@ -822,5 +822,83 @@ " },", ");" ] + }, + "Row": { + "scope": "flutter, dart", + "prefix": "row", + "description": "Creates a `Row` widget, which displays its children in a horizontal array.", + "body": [ + "Row(", + " mainAxisSize: MainAxisSize.${1|min,max|},", + " mainAxisAlignment: MainAxisAlignment.${2|start,end,center,spaceBetween,spaceAround,spaceEvenly|},", + " crossAxisAlignment: CrossAxisAlignment.${3|start,end,center,stretch,baseline|},", + " children: [", + " // SizedBox, Expanded, Flexible, Spacer, VerticalDivider", + " ${0:Placeholder()},", + " ],", + ")," + ] + }, + "Column": { + "scope": "flutter, dart", + "prefix": [ + "col", + "column" + ], + "description": "Creates a `Column` widget, which displays its children in a vertical array.", + "body": [ + "Column(", + " mainAxisSize: MainAxisSize.${1|min,max|},", + " mainAxisAlignment: MainAxisAlignment.${2|start,end,center,spaceBetween,spaceAround,spaceEvenly|},", + " crossAxisAlignment: CrossAxisAlignment.${3|start,end,center,stretch,baseline|},", + " children: [", + " // SizedBox, Expanded, Flexible, Spacer, Divider", + " ${0:Placeholder()},", + " ],", + ")," + ] + }, + "Wrap": { + "scope": "flutter, dart", + "prefix": "wrap", + "description": "Creates a `Wrap` widget, which displays its children in multiple horizontal or vertical runs.", + "body": [ + "Wrap(", + " direction: Axis.${1|horizontal,vertical|},", + " spacing: ${2:8.0},", + " runSpacing: ${3:4.0},", + " alignment: WrapAlignment.${4|start,end,center,spaceBetween,spaceAround,spaceEvenly|},", + " crossAxisAlignment: WrapCrossAlignment.${5|start,end,center|},", + " verticalDirection: VerticalDirection.${6|down,up|},", + " children: [", + " ${0:Placeholder()},", + " ],", + ")," + ] + }, + "Stack": { + "scope": "flutter, dart", + "prefix": "stack", + "description": "Creates a `Stack` widget, which allows you to place widgets on top of each other in a z-order.", + "body": [ + "Stack(", + " alignment: Alignment.${1|topLeft,topCenter,center|},", + " children: [", + " ${0:Placeholder()},", + " ],", + ")," + ] + }, + "FittedBox": { + "scope": "flutter, dart", + "prefix": "fittedbox", + "description": "Creates a `FittedBox` widget, which scales and positions its child within itself according to the specified fit.", + "body": [ + "FittedBox(", + " fit: BoxFit.${1|scaleDown,fill,contain,cover,fitWidth,fitHeight,none|},", + " alignment: Alignment.${2:center},", + " child: ${0:Placeholder()},", + ")," + ] } } \ No newline at end of file From b9ba40d67862ea197db4a35a8ad903c729cb4570 Mon Sep 17 00:00:00 2001 From: Plague Fox Date: Thu, 22 Aug 2024 16:19:25 +0400 Subject: [PATCH 5/5] feat: Add "Wrap with RepaintBoundary" command This commit adds a new command, "Wrap with RepaintBoundary", to the Flutter development extension. The command allows users to easily wrap any widget with a `RepaintBoundary` widget, which isolates the repaint process of the wrapped widget. This can improve performance in complex UIs. Note: This commit message follows the established convention of using a "feat" prefix for new feature additions. --- CONTRIBUTING.md | 17 ++++++++++++++--- README.md | 13 ++++++++++++- package.json | 4 ++++ src/code-actions/code-action-wrap.ts | 5 ++++- src/commands/wrap-with.command.ts | 10 +++++++++- src/extension.ts | 2 ++ 6 files changed, 45 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 07583dd..f9b9763 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ ## How to add widget wrappper -1. Add command to package.json +1. Add command to `package.json` ```json { @@ -17,7 +17,7 @@ } ``` -2. Add snippet to src/commands/wrap-with.command.ts +2. Add snippet to `src/commands/wrap-with.command.ts` ```ts const snippetListenableBuilder = (widget: string) => { @@ -32,7 +32,18 @@ export const wrapWithListenableBuilder = async () => wrapWith(snippetListenableBuilder); ``` -3. Add command to src/extension.ts +3. Add action to `src/code-actions/code-action-wrap.ts` + +```ts + return [ + { + command: "flutter-plus.wrap-listenablebuilder", + title: "Wrap with ListenableBuilder", + } + ] +``` + +4. Add command to `src/extension.ts` ```ts export function activate(context: vscode.ExtensionContext) { diff --git a/README.md b/README.md index c71d552..bc5a954 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,17 @@ Extension add some useful commands to Flutter development in Visual Studio Code. +## Wrap with... + +This package extends your Flutter development experience by providing convenient snippets and commands for wrapping widgets with other commonly used Flutter widgets, similar to the "Wrap with..." functionality in Flutter's built-in extension for VS Code. These additions streamline the process of encapsulating your widgets within other widgets that enhance functionality or control, such as state management, repaint isolation, and more. + +Simply select the widget you want to wrap, and choose the appropriate "Wrap with..." command from the command palette, or use the provided snippets to quickly insert the desired wrapper code into your widget tree. + +- **Wrap with ListenableBuilder**: Easily wrap any widget with a `ListenableBuilder` to rebuild the widget based on changes in a `Listenable` object. +- **Wrap with ValueListenableBuilder**: Automatically wrap your widget with a `ValueListenableBuilder` to react to changes in a `ValueListenable`. +- **Wrap with RepaintBoundary**: Encapsulate your widget within a `RepaintBoundary` to isolate its repaint process, improving performance in complex UIs. + + ## Markdown snippets | Shortcut | Description | @@ -89,4 +100,4 @@ Extension add some useful commands to Flutter development in Visual Studio Code. | col | Creates a `Column` widget, which displays its children in a vertical array. | | wrap | Creates a `Wrap` widget, which displays its children in multiple horizontal or vertical runs, wrapping to the next line when necessary. | | stack | Creates a `Stack` widget, which allows you to place widgets on top of each other in a z-order. | -| fittedbox | Creates a `FittedBox` widget, which scales and positions its child within itself according to the specified fit. | \ No newline at end of file +| fittedbox | Creates a `FittedBox` widget, which scales and positions its child within itself according to the specified fit. | diff --git a/package.json b/package.json index af03f48..5e17d28 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,10 @@ { "command": "flutter-plus.wrap-valuelistenablebuilder", "title": "Wrap with ValueListenableBuilder" + }, + { + "command": "flutter-plus.wrap-repaintboundary", + "title": "Wrap with RepaintBoundary" } ], "submenus": [ diff --git a/src/code-actions/code-action-wrap.ts b/src/code-actions/code-action-wrap.ts index effa2ae..6dca3be 100644 --- a/src/code-actions/code-action-wrap.ts +++ b/src/code-actions/code-action-wrap.ts @@ -4,7 +4,6 @@ import { CodeAction, CodeActionKind, CodeActionProvider, window } from "vscode"; import { getSelectedText } from "../utils"; export class CodeActionWrap implements CodeActionProvider { - public provideCodeActions(): CodeAction[] { const editor = window.activeTextEditor; if (!editor) return []; @@ -22,6 +21,10 @@ export class CodeActionWrap implements CodeActionProvider { title: "Wrap with ValueListenableBuilder", }, /* TODO: Convert between ListenableBuilder <--> ValueListenableBuilder */ + { + command: "flutter-plus.wrap-repaintboundary", + title: "Wrap with RepaintBoundary", + } ].map((c) => { let action = new CodeAction(c.title, CodeActionKind.Refactor); action.command = { diff --git a/src/commands/wrap-with.command.ts b/src/commands/wrap-with.command.ts index 288996f..e1c8bdb 100644 --- a/src/commands/wrap-with.command.ts +++ b/src/commands/wrap-with.command.ts @@ -16,6 +16,14 @@ const snippetValueListenableBuilder = (widget: string) => { )`; }; +const snippetRepaintBoundary = (widget: string) => { + return `RepaintBoundary( + child: ${widget}, +)`; +}; + export const wrapWithListenableBuilder = async () => wrapWith(snippetListenableBuilder); -export const wrapWithValueListenableBuilder = async () => wrapWith(snippetValueListenableBuilder); \ No newline at end of file +export const wrapWithValueListenableBuilder = async () => wrapWith(snippetValueListenableBuilder); + +export const wrapWithRepaintBoundary = async () => wrapWith(snippetRepaintBoundary); \ No newline at end of file diff --git a/src/extension.ts b/src/extension.ts index bb5108c..7179791 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -8,6 +8,7 @@ import { import { sealedStates, wrapWithListenableBuilder, + wrapWithRepaintBoundary, wrapWithValueListenableBuilder, } from "./commands"; @@ -27,6 +28,7 @@ export function activate(context: vscode.ExtensionContext) { commands.registerCommand("flutter-plus.sealed-states", sealedStates), commands.registerCommand("flutter-plus.wrap-listenablebuilder", wrapWithListenableBuilder), commands.registerCommand("flutter-plus.wrap-valuelistenablebuilder", wrapWithValueListenableBuilder), + commands.registerCommand("flutter-plus.wrap-repaintboundary", wrapWithRepaintBoundary), languages.registerCodeActionsProvider( DART_MODE,