├── .github └── workflows │ ├── main.yml │ └── open-vsx.yml ├── .gitignore ├── .vscode └── launch.json ├── .vscodeignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── gifs └── greetingProvider.gif ├── logo.jpg ├── package.json └── snippets ├── async_notifier.code-snippets ├── async_notifier_provider.code-snippets ├── change_notifier.code-snippets ├── change_notifier_provider.code-snippets ├── code_generator.code-snippets ├── consumer.code-snippets ├── consumer_widgets.code-snippets ├── future_provider.code-snippets ├── hook_consumer.code-snippets ├── notifier.code-snippets ├── notifier_provider.code-snippets ├── provider.code-snippets ├── provider_listenable.code-snippets ├── state_notifier.code-snippets ├── state_notifier_provider.code-snippets ├── state_provider.code-snippets ├── stream_notifier.code-snippets ├── stream_notifier_provider.code-snippets └── stream_provider.code-snippets /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Extension 2 | 3 | on: [workflow_dispatch] 4 | 5 | jobs: 6 | deploy-to-vscode: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - run: npm install 11 | - uses: lannonbr/vsce-action@master 12 | with: 13 | args: "publish -p $VSCE_TOKEN" 14 | env: 15 | VSCE_TOKEN: ${{ secrets.VSCE_TOKEN }} -------------------------------------------------------------------------------- /.github/workflows/open-vsx.yml: -------------------------------------------------------------------------------- 1 | name: Deploy to open-vsx 2 | 3 | on: [workflow_dispatch] 4 | 5 | jobs: 6 | deploy-to-open-vsx: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - uses: actions/setup-node@v1 11 | with: 12 | node-version: 16 13 | - uses: HaaLeo/publish-vscode-extension@v1 14 | with: 15 | pat: ${{ secrets.OPEN_VSX_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.vsix 3 | vsc-extension-quickstart.md -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "runtimeExecutable": "${execPath}", 13 | "args": [ 14 | "--extensionDevelopmentPath=${workspaceFolder}" 15 | ] 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | .gitignore 4 | vsc-extension-quickstart.md 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the **flutter-riverpod-snippets** extension will be documented in this file. 4 | 5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 6 | 7 | ### [1.2.2] 8 | 9 | ### Add 10 | - Support for `Riverpod` **v2.3** 11 | - `riverpodStream`, `riverpodStreamKeepAlive`, `riverpodStreamClass`, `riverpodStreamClassKeepAlive` 12 | - `streamNotifierProvider`, `streamNotifierProviderFamily`, `streamNotifier`, `streamNotifierFamily`, 13 | 14 | ### [1.2.1] 15 | - fix `Notifier`, `AsyncNotifier` and `ChangeNotifier` snippets 16 | ### [1.2.0] 17 | 18 | ### Add 19 | - Support for `Riverpod` **v2.0** 20 | - `riverpod`, `riverpodKeepAlive`, `riverpodFuture`, `riverpodFutureKeepAlive`, `riverpodClass`, `riverpodClassKeepAlive`, `riverpodAsyncClass`, `riverpodAsyncClassKeepAlive`, `riverpodPart` 21 | - `asyncNotifierProvider`, `asyncNotifierProviderFamily`, `asyncNotifier`, `asyncNotifierFamily`, `notifierProvider`, `notifierProviderFamily`, `notifier`, `notifierFamily` 22 | 23 | ### [1.1.2] 24 | 25 | ### Update 26 | 27 | - Convert snippets to superclass shorthand syntax 28 | 29 | ### [1.1.1] 30 | 31 | ### Fix 32 | 33 | - Fix `listen` snippet to use previous & next 34 | 35 | ### [1.1.0] 36 | 37 | ### Add 38 | 39 | - `StatefulHookConsumerWidget`. 40 | 41 | ### Update 42 | 43 | - Replace `hookConsumer` prefix with `stlessHookConsumer`. 44 | 45 | ### Fix 46 | 47 | - Add Constructor with `key` to `ConsumerStatefulWidget`. 48 | 49 | ### [1.0.2] 50 | 51 | ### Fix 52 | 53 | - `consumer` not using `ref` but instead `watch`. 54 | 55 | ### [1.0.1] 56 | 57 | ### Fix 58 | 59 | - `stfulConsumer` and `stlessConsumer` snippet. 60 | 61 | ### Remove 62 | 63 | - `scopedProvider` snippet. 64 | 65 | ### [1.0.0] 66 | 67 | ### Add 68 | 69 | - Support for `Riverpod` **v1.0** 70 | - `ConsumerStatelessWidget`, `ConsumerStatefulWidget`, `HookConsumerWidget`. 71 | 72 | ### [0.2.1] 73 | 74 | ### Update 75 | 76 | - Update logo 77 | 78 | ### [0.2.0] 79 | 80 | ### Add 81 | 82 | - Support for all types of `Providers`, `ChangeNotifier` and `StateNotifier` 83 | 84 | ### [0.1.1] 85 | 86 | ### Add 87 | 88 | - Support for Riverpod ^0.6.0 89 | 90 | ### [0.1.0] 91 | 92 | ### Add 93 | 94 | - Initial release of Flutter Riverpod snippets 95 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Robert Brunhage 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flutter Riverpod Snippets 2 | 3 | Flutter Riverpod snippets is a way to enhance the way you use Riverpod. It contains a collection of different 4 | snippets such as `provider`. 5 | 6 | ![greetingProviderGif](gifs/greetingProvider.gif) 7 | 8 | ## Snippets 9 | 10 | | Shortcut | Description | 11 | | ------------------------------ | --------------------------------------------------------------------------- | 12 | | `consumer` | Creates the Consumer widget | 13 | | `stlessConsumer` | Creates a ConsumerStateless widget | 14 | | `stfulConsumer` | Creates a ConsumerStateful widget | 15 | | `stlessHookConsumer` | Creates a Stateless HookConsumer widget | 16 | | `stfulHookConsumer` | Creates a Stateful HookConsumer widget | 17 | | `provider` | Creates a simple riverpod provider | 18 | | `providerFamily` | Creates a provider with the family modifier | 19 | | `futureProvider` | Creates a FutureProvider | 20 | | `futureProviderFamily` | Creates a FutureProvider with the family modifier | 21 | | `streamProvider` | Creates a StreamProvider | 22 | | `streamProviderFamily` | Creates a StreamProvider with the family modifier | 23 | | `changeNotifierProvider` | Creates a ChangeNotifierProvider | 24 | | `changeNotifierProviderFamily` | Creates a ChangeNotifierProvider with the family modifier | 25 | | `stateProvider` | Creates a StateProvider | 26 | | `stateProviderFamily` | Creates a StateProvider with the family modifier | 27 | | `stateProviderFamily` | Creates a StateProvider with the family modifier | 28 | | `stateNotifierProvider` | Creates a StateNotifier provider | 29 | | `stateNotifierProviderFamily` | Creates a StateNotifierProvider with the family modifier | 30 | | `stateNotifier` | Creates a class that extends StateNotifier and allows you to edit the types | 31 | | `asyncNotifierProvider` | Create an AsyncNotifierProvider | 32 | | `asyncNotifierProviderFamily` | Create an AsyncNotifierProvider with Family Modifier | 33 | | `asyncNotifier` | Create an AsyncNotifier class | 34 | | `asyncNotifierFamily` | Create an AsyncNotifier with Family Parameter | 35 | | `notifierProvider` | Create a NotifierProvider | 36 | | `notifierProviderFamily` | Create a NotifierProvider with Family Modifier | 37 | | `notifier` | Create a Notifier class | 38 | | `notifierFamily` | Create a Notifier with Family Parameter | 39 | | `streamNotifierProvider` | Create an StreamNotifierProvider | 40 | | `streamNotifierProviderFamily` | Create an StreamNotifierProvider with Family Modifier | 41 | | `streamNotifier` | Create an StreamNotifier class | 42 | | `streamNotifierFamily` | Create an StreamNotifier with Family Parameter | 43 | | `listen` | Creates a Provider Listenable | 44 | | `riverpod` | Creates a simple Provider | 45 | | `riverpodKeepAlive` | Creates a simple keep alive Provider | 46 | | `riverpodFuture` | Creates a FutureProvider | 47 | | `riverpodFutureKeepAlive` | Creates a keep alive FutureProvider | 48 | | `riverpodStream` | Creates a StreamProvider | 49 | | `riverpodStreamKeepAlive` | Creates a keep alive StreamProvider | 50 | | `riverpodClass` | Creates a class Provider | 51 | | `riverpodClassKeepAlive` | Creates a keep alive class Provider | 52 | | `riverpodAsyncClass` | Creates an async class Provider | 53 | | `riverpodAsyncClassKeepAlive` | Creates a keep alive async class Provider | 54 | | `riverpodStreamClass` | Creates an stream class Provider | 55 | | `riverpodStreamClassKeepAlive` | Creates a keep alive stream class Provider | 56 | | `riverpodPart` | Create a part statement for Riverpod | 57 | 58 | ## Contributing 59 | Feel free to open PRs for small issues such as typos. For large issues or features, please open an issue first. 60 | 61 | ### How to do it 62 | First fork the repo on [GitHub](https://github.com/RobertBrunhage/flutter-riverpod-snippets). 63 | ``` 64 | git clone 65 | 66 | git switch -c my-fix 67 | # fix some code... 68 | 69 | git commit -m "Fix typo in readme" 70 | git push origin my-fix 71 | ``` 72 | 73 | The commit naming follows [this structure](https://chris.beams.io/posts/git-commit/) 74 | 75 | Add the changes done to `CHANGELOG.md` and update the version in `package.json` 76 | 77 | ## Release Notes 78 | 79 | Please check [Changelog](CHANGELOG.md) 80 | -------------------------------------------------------------------------------- /gifs/greetingProvider.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RobertBrunhage/flutter-riverpod-snippets/ee10f52d4e2f75bf3ac3fa67d441b493e5770fbc/gifs/greetingProvider.gif -------------------------------------------------------------------------------- /logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RobertBrunhage/flutter-riverpod-snippets/ee10f52d4e2f75bf3ac3fa67d441b493e5770fbc/logo.jpg -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter-riverpod-snippets", 3 | "displayName": "Flutter Riverpod Snippets", 4 | "description": "Quick and easy Flutter Riverpod snippets", 5 | "icon": "logo.jpg", 6 | "version": "1.2.2", 7 | "publisher": "robert-brunhage", 8 | "homepage": "https://github.com/RobertBrunhage/flutter-riverpod-snippets", 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/RobertBrunhage/flutter-riverpod-snippets" 12 | }, 13 | "keywords": [ 14 | "Flutter", 15 | "Dart", 16 | "Snippets", 17 | "Riverpod" 18 | ], 19 | "engines": { 20 | "vscode": "^1.62.3" 21 | }, 22 | "categories": [ 23 | "Snippets" 24 | ], 25 | "contributes": { 26 | "snippets": [ 27 | { 28 | "language": "dart", 29 | "path": "./snippets/async_notifier_provider.code-snippets" 30 | }, 31 | { 32 | "language": "dart", 33 | "path": "./snippets/async_notifier.code-snippets" 34 | }, 35 | { 36 | "language": "dart", 37 | "path": "./snippets/notifier_provider.code-snippets" 38 | }, 39 | { 40 | "language": "dart", 41 | "path": "./snippets/notifier.code-snippets" 42 | }, 43 | { 44 | "language": "dart", 45 | "path": "./snippets/stream_notifier_provider.code-snippets" 46 | }, 47 | { 48 | "language": "dart", 49 | "path": "./snippets/stream_notifier.code-snippets" 50 | }, 51 | { 52 | "language": "dart", 53 | "path": "./snippets/consumer.code-snippets" 54 | }, 55 | { 56 | "language": "dart", 57 | "path": "./snippets/change_notifier_provider.code-snippets" 58 | }, 59 | { 60 | "language": "dart", 61 | "path": "./snippets/change_notifier.code-snippets" 62 | }, 63 | { 64 | "language": "dart", 65 | "path": "./snippets/future_provider.code-snippets" 66 | }, 67 | { 68 | "language": "dart", 69 | "path": "./snippets/provider.code-snippets" 70 | }, 71 | { 72 | "language": "dart", 73 | "path": "./snippets/state_notifier.code-snippets" 74 | }, 75 | { 76 | "language": "dart", 77 | "path": "./snippets/state_notifier_provider.code-snippets" 78 | }, 79 | { 80 | "language": "dart", 81 | "path": "./snippets/state_provider.code-snippets" 82 | }, 83 | { 84 | "language": "dart", 85 | "path": "./snippets/stream_provider.code-snippets" 86 | }, 87 | { 88 | "language": "dart", 89 | "path": "./snippets/consumer_widgets.code-snippets" 90 | }, 91 | { 92 | "language": "dart", 93 | "path": "./snippets/hook_consumer.code-snippets" 94 | }, 95 | { 96 | "language": "dart", 97 | "path": "./snippets/provider_listenable.code-snippets" 98 | }, 99 | { 100 | "language": "dart", 101 | "path": "./snippets/code_generator.code-snippets" 102 | } 103 | ] 104 | } 105 | } -------------------------------------------------------------------------------- /snippets/async_notifier.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Riverpod: AsyncNotifier class": { 3 | "scope": "dart", 4 | "prefix": "asyncNotifier", 5 | "description": "Create an AsyncNotifier class", 6 | "body": [ 7 | "class $1Notifier extends AsyncNotifier<$2> {", 8 | "\t@override", 9 | "\tFutureOr<$2> build() {", 10 | "\t\treturn $3;", 11 | "\t}", 12 | "}" 13 | ] 14 | }, 15 | "Riverpod: Family AsyncNotifier class": { 16 | "scope": "dart", 17 | "prefix": "asyncNotifierFamily", 18 | "description": "Create an AsyncNotifier with Family Parameter", 19 | "body": [ 20 | "class $1Notifier extends FamilyAsyncNotifier<$2, $3> {", 21 | "\t@override", 22 | "\tFutureOr<$2> build($3 arg) {", 23 | "\t\treturn $4;", 24 | "\t}", 25 | "}" 26 | ] 27 | }, 28 | } -------------------------------------------------------------------------------- /snippets/async_notifier_provider.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Riverpod: AsyncNotifier Provider": { 3 | "scope": "dart", 4 | "prefix": "asyncNotifierProvider", 5 | "description": "Create an AsyncNotifierProvider", 6 | "body": [ 7 | "final $1Provider = AsyncNotifierProvider<$2, $3>($2.new);", 8 | ] 9 | }, 10 | "Riverpod: AsyncNotifier Provider with Family": { 11 | "scope": "dart", 12 | "prefix": "asyncNotifierProviderFamily", 13 | "description": "Create an AsyncNotifierProvider with Family Modifier", 14 | "body": [ 15 | "final $1Provider = AsyncNotifierProviderFamily<$2, $3, $4>($2.new);", 16 | ] 17 | }, 18 | } -------------------------------------------------------------------------------- /snippets/change_notifier.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "State Notifier": { 3 | "scope": "dart", 4 | "prefix": "changeNotifier", 5 | "description": "Create a ChangeNotifier with Editable Parameter", 6 | "body": [ 7 | "class $1Notifier extends ChangeNotifier {", 8 | "\t$2", 9 | "}" 10 | ] 11 | } 12 | } -------------------------------------------------------------------------------- /snippets/change_notifier_provider.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Change Notifier Provider": { 3 | "scope": "dart", 4 | "prefix": "changeNotifierProvider", 5 | "description": "Create a ChangeNotifierProvider", 6 | "body": [ 7 | "final $1Provider = ChangeNotifierProvider<$2>((ref) {", 8 | "\treturn $3;", 9 | "});" 10 | ] 11 | }, 12 | "Change Notifier Provider with Family": { 13 | "scope": "dart", 14 | "prefix": "changeNotifierProviderFamily", 15 | "description": "Create a ChangeNotifierProvider with Family modifier", 16 | "body": [ 17 | "final $1Provider = ChangeNotifierProvider.family<$2, $3>((ref, $4) {", 18 | "\treturn $5;", 19 | "});" 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /snippets/code_generator.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Riverpod: part statement": { 3 | "scope": "dart", 4 | "prefix": "riverpodPart", 5 | "description": "Create a part statement for Riverpod", 6 | "body": [ 7 | "part '${TM_FILENAME_BASE}.g.dart';", 8 | ] 9 | }, 10 | "Riverpod: simple instance": { 11 | "scope": "dart", 12 | "prefix": "riverpod", 13 | "description": "Creates a simple Provider", 14 | "body": [ 15 | "@riverpod", 16 | "$1 $2(${2/(.*)/${1:/capitalize}/}Ref ref) {", 17 | "\treturn $3;", 18 | "}", 19 | ] 20 | }, 21 | "Riverpod: simple keep alive instance": { 22 | "scope": "dart", 23 | "prefix": "riverpodKeepAlive", 24 | "description": "Creates a simple keep alive Provider", 25 | "body": [ 26 | "@Riverpod(keepAlive: true)", 27 | "$1 $2(${2/(.*)/${1:/capitalize}/}Ref ref) {", 28 | "\treturn $3;", 29 | "}", 30 | ] 31 | }, 32 | "Riverpod: future instance": { 33 | "scope": "dart", 34 | "prefix": "riverpodFuture", 35 | "description": "Creates a FutureProvider", 36 | "body": [ 37 | "@riverpod", 38 | "FutureOr<$1> $2(${2/(.*)/${1:/capitalize}/}Ref ref) {", 39 | "\treturn $3;", 40 | "}", 41 | ] 42 | }, 43 | "Riverpod: keep alive future instance": { 44 | "scope": "dart", 45 | "prefix": "riverpodFutureKeepAlive", 46 | "description": "Creates a keep alive FutureProvider", 47 | "body": [ 48 | "@Riverpod(keepAlive: true)", 49 | "FutureOr<$1> $2(${2/(.*)/${1:/capitalize}/}Ref ref) {", 50 | "\treturn $3;", 51 | "}", 52 | ] 53 | }, 54 | "Riverpod: stream instance": { 55 | "scope": "dart", 56 | "prefix": "riverpodStream", 57 | "description": "Creates a StreamProvider", 58 | "body": [ 59 | "@riverpod", 60 | "Stream<$1> $2(${2/(.*)/${1:/capitalize}/}Ref ref) {", 61 | "\treturn $3;", 62 | "}", 63 | ] 64 | }, 65 | "Riverpod: keep alive stream instance": { 66 | "scope": "dart", 67 | "prefix": "riverpodStreamKeepAlive", 68 | "description": "Creates a keep alive StreamProvider", 69 | "body": [ 70 | "@Riverpod(keepAlive: true)", 71 | "Stream<$1> $2(${2/(.*)/${1:/capitalize}/}Ref ref) {", 72 | "\treturn $3;", 73 | "}", 74 | ] 75 | }, 76 | "Riverpod: class": { 77 | "scope": "dart", 78 | "prefix": "riverpodClass", 79 | "description": "Creates a class Provider", 80 | "body": [ 81 | "@riverpod", 82 | "class $1 extends _$$1 {", 83 | "\t@override", 84 | "\t$2 build() {", 85 | "\t\treturn $3;", 86 | "\t}", 87 | "}", 88 | ] 89 | }, 90 | "Riverpod: keep alive class": { 91 | "scope": "dart", 92 | "prefix": "riverpodClassKeepAlive", 93 | "description": "Creates a keep alive class Provider", 94 | "body": [ 95 | "@Riverpod(keepAlive: true)", 96 | "class $1 extends _$$1 {", 97 | "\t@override", 98 | "\t$2 build() {", 99 | "\t\treturn $3;", 100 | "\t}", 101 | "}", 102 | ] 103 | }, 104 | "Riverpod: async class": { 105 | "scope": "dart", 106 | "prefix": "riverpodAsyncClass", 107 | "description": "Creates an async class Provider", 108 | "body": [ 109 | "@riverpod", 110 | "class $1 extends _$$1 {", 111 | "\t@override", 112 | "\tFutureOr<$2> build() {", 113 | "\t\treturn $3;", 114 | "\t}", 115 | "}", 116 | ] 117 | }, 118 | "Riverpod: keep alive async class": { 119 | "scope": "dart", 120 | "prefix": "riverpodAsyncClassKeepAlive", 121 | "description": "Creates a keep alive async class Provider", 122 | "body": [ 123 | "@Riverpod(keepAlive: true)", 124 | "class $1 extends _$$1 {", 125 | "\t@override", 126 | "\tFutureOr<$2> build() {", 127 | "\t\treturn $3;", 128 | "\t}", 129 | "}", 130 | ] 131 | }, 132 | "Riverpod: stream class": { 133 | "scope": "dart", 134 | "prefix": "riverpodStreamClass", 135 | "description": "Creates an stream class Provider", 136 | "body": [ 137 | "@riverpod", 138 | "class $1 extends _$$1 {", 139 | "\t@override", 140 | "\tStream<$2> build() {", 141 | "\t\treturn $3;", 142 | "\t}", 143 | "}", 144 | ] 145 | }, 146 | "Riverpod: keep alive stream class": { 147 | "scope": "dart", 148 | "prefix": "riverpodStreamClassKeepAlive", 149 | "description": "Creates a keep alive stream class Provider", 150 | "body": [ 151 | "@Riverpod(keepAlive: true)", 152 | "class $1 extends _$$1 {", 153 | "\t@override", 154 | "\tStream<$2> build() {", 155 | "\t\treturn $3;", 156 | "\t}", 157 | "}", 158 | ] 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /snippets/consumer.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "create provider": { 3 | "scope": "dart", 4 | "prefix": "consumer", 5 | "body": [ 6 | "Consumer(", 7 | "\tbuilder: (context, ref, child) {", 8 | "\t\treturn $1;", 9 | "\t},", 10 | ")" 11 | ], 12 | "description": "Creates a consumer" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /snippets/consumer_widgets.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Consumer Stateless": { 3 | "scope": "dart", 4 | "prefix": "stlessConsumer", 5 | "description": "Create a ConsumerStatelessWidget", 6 | "body": [ 7 | "class $1 extends ConsumerWidget {", 8 | "\tconst $1({super.key});\n", 9 | "\t@override", 10 | "\tWidget build(BuildContext context, WidgetRef ref) {", 11 | "\t\treturn Container();", 12 | "\t}", 13 | "}" 14 | ] 15 | }, 16 | "Consumer Stateful": { 17 | "scope": "dart", 18 | "prefix": "stfulConsumer", 19 | "description": "Create a ConsumerStatefulWidget", 20 | "body": [ 21 | "class $1 extends ConsumerStatefulWidget {", 22 | "\tconst $1({super.key});\n", 23 | "\t@override", 24 | "\tConsumerState createState() => _$1State();", 25 | "}\n", 26 | "class _$1State extends ConsumerState<$1> {\n", 27 | "\t@override", 28 | "\tWidget build(BuildContext context) {", 29 | "\t\treturn Container();", 30 | "\t}", 31 | "}" 32 | ] 33 | } 34 | } -------------------------------------------------------------------------------- /snippets/future_provider.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Future Provider": { 3 | "scope": "dart", 4 | "prefix": "futureProvider", 5 | "description": "Create a FutureProvider", 6 | "body": [ 7 | "final $1Provider = FutureProvider<$2>((ref) async {", 8 | "\treturn $3;", 9 | "});" 10 | ] 11 | }, 12 | "Future Provider with Family": { 13 | "scope": "dart", 14 | "prefix": "futureProviderFamily", 15 | "description": "Create a FutureProvider with Family", 16 | "body": [ 17 | "final $1Provider = FutureProvider.family<$2, $3>((ref, $4) async {", 18 | "\treturn $5;", 19 | "});" 20 | ] 21 | } 22 | } -------------------------------------------------------------------------------- /snippets/hook_consumer.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Hook Consumer Stateless Widget": { 3 | "scope": "dart", 4 | "prefix": "stlessHookConsumer", 5 | "description": "Create a HookConsumerWidget", 6 | "body": [ 7 | "class $1 extends HookConsumerWidget {", 8 | "\tconst $1({super.key});", 9 | 10 | "\t@override", 11 | "\tWidget build(BuildContext context, WidgetRef ref) {", 12 | "\t\treturn Container();", 13 | "\t}", 14 | "}" 15 | ] 16 | }, 17 | "Hook Consumer Stateful Widget": { 18 | "scope": "dart", 19 | "prefix": "stfulHookConsumer", 20 | "description": "Create a StatefulHookConsumerWidget", 21 | "body": [ 22 | "class $1 extends StatefulHookConsumerWidget {", 23 | "\tconst $1({super.key});\n", 24 | "\t@override", 25 | "\tConsumerState createState() => _$1State();", 26 | "}", 27 | 28 | "class _$1State extends ConsumerState<$1> {", 29 | 30 | "\t@override", 31 | "\tWidget build(BuildContext context) {", 32 | "\t\treturn Container();", 33 | "\t}", 34 | "}" 35 | ] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /snippets/notifier.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Riverpod: Notifier class": { 3 | "scope": "dart", 4 | "prefix": "notifier", 5 | "description": "Create a Notifier class", 6 | "body": [ 7 | "class $1Notifier extends Notifier<$2> {", 8 | "\t@override", 9 | "\t$2 build() {", 10 | "\t\treturn $3;", 11 | "\t}", 12 | "}" 13 | ] 14 | }, 15 | "Riverpod: Family Notifier class": { 16 | "scope": "dart", 17 | "prefix": "notifierFamily", 18 | "description": "Create a Notifier with Editable Parameter", 19 | "body": [ 20 | "class $1Notifier extends FamilyNotifier<$2, $3> {", 21 | "\t@override", 22 | "\t$2 build($3 arg) {", 23 | "\t\treturn $4;", 24 | "\t}", 25 | "}" 26 | ] 27 | }, 28 | } -------------------------------------------------------------------------------- /snippets/notifier_provider.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Riverpod: Notifier Provider": { 3 | "scope": "dart", 4 | "prefix": "notifierProvider", 5 | "description": "Create a NotifierProvider", 6 | "body": [ 7 | "final $1Provider = NotifierProvider<$2, $3>($2.new);", 8 | ] 9 | }, 10 | "Riverpod: Notifier Provider with Family": { 11 | "scope": "dart", 12 | "prefix": "notifierProviderFamily", 13 | "description": "Create a NotifierProvider with Family Modifier", 14 | "body": [ 15 | "final $1Provider = NotifierProviderFamily<$2, $3, $4>($2.new);", 16 | ] 17 | }, 18 | } -------------------------------------------------------------------------------- /snippets/provider.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Provider": { 3 | "scope": "dart", 4 | "prefix": "provider", 5 | "description": "Create a simple Provider", 6 | "body": [ 7 | "final $1Provider = Provider<$2>((ref) {", 8 | "\treturn $3;", 9 | "});", 10 | ] 11 | }, 12 | "Provider with Family": { 13 | "scope": "dart", 14 | "prefix": "providerFamily", 15 | "description": "Create a simple Provider with Family modifier", 16 | "body": [ 17 | "final $1Provider = Provider.family<$2, $3>((ref, $4) {", 18 | "\treturn $5;", 19 | "});" 20 | ] 21 | } 22 | } -------------------------------------------------------------------------------- /snippets/provider_listenable.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Provider Listenable": { 3 | "scope": "dart", 4 | "prefix": "listen", 5 | "description": "Create a provider listenable", 6 | "body": [ 7 | "ref.listen<$1>($2, (previous, next) { ", 8 | "\t$3", 9 | "});" 10 | ] 11 | } 12 | } -------------------------------------------------------------------------------- /snippets/state_notifier.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "State Notifier": { 3 | "scope": "dart", 4 | "prefix": "stateNotifier", 5 | "description": "Create a StateNotifier with Editable Parameter", 6 | "body": [ 7 | "class $1Notifier extends StateNotifier<$2> {", 8 | "\t$1Notifier(): super($3);", 9 | "\t$4", 10 | "}" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /snippets/state_notifier_provider.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "State Notifier Provider": { 3 | "scope": "dart", 4 | "prefix": "stateNotifierProvider", 5 | "description": "Create a StateNotifierProvider", 6 | "body": [ 7 | "final $1Provider = StateNotifierProvider<$2>((ref) {", 8 | "\treturn $3", 9 | "});" 10 | ] 11 | }, 12 | "State Notifier Provider with Family": { 13 | "scope": "dart", 14 | "prefix": "stateNotifierProviderFamily", 15 | "description": "Create a StateNotifierProvider with Family Modifier", 16 | "body": [ 17 | "final $1Provider = StateNotifierProvider.family<$2, $3>((ref, $4) {", 18 | "\treturn $5", 19 | "});" 20 | ] 21 | } 22 | } -------------------------------------------------------------------------------- /snippets/state_provider.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "State Provider": { 3 | "scope": "dart", 4 | "prefix": "stateProvider", 5 | "description": "Create a StateProvider", 6 | "body": [ 7 | "final $1Provider = StateProvider<$2>((ref) {", 8 | "\treturn $3;", 9 | "});", 10 | ] 11 | }, 12 | "State Provider Family": { 13 | "scope": "dart", 14 | "prefix": "stateProviderFamily", 15 | "description": "Create a StateProvider with Family modifier", 16 | "body": [ 17 | "final $1Provider = StateProvider.family<$2, $3>((ref, $4) {", 18 | "\treturn $5;", 19 | "});" 20 | ] 21 | } 22 | } -------------------------------------------------------------------------------- /snippets/stream_notifier.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Riverpod: StreamNotifier class": { 3 | "scope": "dart", 4 | "prefix": "streamNotifier", 5 | "description": "Create an StreamNotifier class", 6 | "body": [ 7 | "class $1Notifier extends StreamNotifier<$2> {", 8 | "\t@override", 9 | "\tStream<$2> build() {", 10 | "\t\treturn $3;", 11 | "\t}", 12 | "}" 13 | ] 14 | }, 15 | "Riverpod: Family StreamNotifier class": { 16 | "scope": "dart", 17 | "prefix": "streamNotifierFamily", 18 | "description": "Create an StreamNotifier with Family Parameter", 19 | "body": [ 20 | "class $1Notifier extends FamilyStreamNotifier<$2, $3> {", 21 | "\t@override", 22 | "\tStream<$2> build($3 arg) {", 23 | "\t\treturn $4;", 24 | "\t}", 25 | "}" 26 | ] 27 | }, 28 | } -------------------------------------------------------------------------------- /snippets/stream_notifier_provider.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Riverpod: StreamNotifier Provider": { 3 | "scope": "dart", 4 | "prefix": "streamNotifierProvider", 5 | "description": "Create an StreamNotifierProvider", 6 | "body": [ 7 | "final $1Provider = StreamNotifierProvider<$2, $3>($2.new);", 8 | ] 9 | }, 10 | "Riverpod: StreamNotifier Provider with Family": { 11 | "scope": "dart", 12 | "prefix": "streamNotifierProviderFamily", 13 | "description": "Create an StreamNotifierProvider with Family Modifier", 14 | "body": [ 15 | "final $1Provider = StreamNotifierProviderFamily<$2, $3, $4>($2.new);", 16 | ] 17 | }, 18 | } -------------------------------------------------------------------------------- /snippets/stream_provider.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "State Provider": { 3 | "scope": "dart", 4 | "prefix": "streamProvider", 5 | "description": "Create a StreamProvider", 6 | "body": [ 7 | "final $1Provider = StreamProvider<$2>((ref) async* {", 8 | "\treturn $3;", 9 | "});" 10 | ] 11 | }, 12 | "State Provider Family": { 13 | "scope": "dart", 14 | "prefix": "streamProviderFamily", 15 | "description": "Create a StreamProvider with Family modifier", 16 | "body": [ 17 | "final $1Provider = StreamProvider.family<$2, $3>((ref, $4) async* {", 18 | "\treturn $5;", 19 | "});" 20 | ] 21 | } 22 | } --------------------------------------------------------------------------------