Shortcuts & Snippets

Speed up your Riverpod development with these IDE shortcuts and code snippets. Available for VS Code, IntelliJ IDEA, and Android Studio.

VS Code Snippets

Type these prefixes in VS Code and press Tab to expand:

Provider Snippets

rprovBasic Provider
provider.dart
@riverpod
ReturnType providerName(ProviderNameRef ref) {
  return value;
}
rnotifierNotifier Class
notifier.dart
@riverpod
class ClassName extends _$ClassName {
  @override
  StateType build() {
    return initialState;
  }
}
rfutureFuture Provider
future_provider.dart
@riverpod
Future<ReturnType> providerName(ProviderNameRef ref) async {
  return await asyncOperation();
}
rstreamStream Provider
stream_provider.dart
@riverpod
Stream<ReturnType> providerName(ProviderNameRef ref) async* {
  yield* streamSource();
}

Family Providers

rfamilyFamily Provider
family_provider.dart
@riverpod
ReturnType providerName(ProviderNameRef ref, ParamType param) {
  return computeValue(param);
}
rfamnotifierFamily Notifier
family_notifier.dart
@riverpod
class ClassName extends _$ClassName {
  @override
  StateType build(ParamType param) {
    return initialState(param);
  }
}

IntelliJ/Android Studio Templates

Live templates for JetBrains IDEs. Go to Settings > Editor > Live Templates and import our template set.

Live Template Demo
Using live templates in IntelliJ IDEA to generate provider code

Keyboard Shortcuts

Essential keyboard shortcuts for Riverpod development:

ActionVS CodeIntelliJ
Build RunnerCtrl+Shift+P -> build_runnerCtrl+Alt+B
Generate Part FileCtrl+. -> Add part directiveAlt+Enter
Import RiverpodCtrl+Space auto-importAlt+Enter

Custom Snippets

Create your own custom snippets for common patterns in your project. Here's how to add custom VS Code snippets:

  1. 1Go to File > Preferences > Configure User Snippets
  2. 2Select dart.json or create a new snippet file
  3. 3Add your custom snippet configuration

Pro Tips