Search packages, repositories and app categories

Package detailsv4.0.9

riverpod_generator

A code generator for Riverpod. This both simplifies the syntax empowers it, such as allowing stateful hot-reload.

AndroidiOSmacOSWindowsLinux
30-day downloads
1.1M
Likes
437
Pub points
130

Install package

flutter pub add riverpod_generator

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Riverpod_generator is a code generation tool for the Riverpod state management library in Flutter. It simplifies boilerplate by automatically generating provider definitions, enabling cleaner syntax and enhanced developer experience. The generator supports stateful hot-reload, allowing state to persist during development without restarts. It integrates seamlessly with Riverpod’s ecosystem, reducing manual coding and improving maintainability. Designed for performance and ease of use, it helps developers focus on logic rather than repetitive setup.

Use cases

  • Simplifying complex provider declarations
  • Enabling stateful hot-reload in development
  • Reducing boilerplate in large-scale apps
  • Automating provider creation across multiple files
  • Improving code readability and maintainability

Key features

  • Automatic provider code generation
  • Supports stateful hot-reload
  • Reduces manual boilerplate
  • Integrates with Riverpod's API
  • Generates type-safe code

Suitable for

  • Flutter developers using Riverpod
  • Teams building scalable state-managed apps
  • Developers seeking faster iteration with hot-reload
  • Projects requiring clean, maintainable state logic
  • Those wanting to minimize repetitive provider setup

Considerations

  • Requires Dart code generation setup
  • Needs proper build_runner configuration
  • May increase build time slightly
  • Depends on Riverpod core package
  • Not needed for simple, hand-written providers

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Build Status codecov Star on Github License: MIT Discord

Deploys by Netlify

Riverpod


A reactive caching and data-binding framework. https://riverpod.dev Riverpod makes working with asynchronous code a breeze by:

  • Handling errors/loading states by default. No need to manually catch errors
  • Natively supporting advanced scenarios, such as pull-to-refresh
  • Separating the logic from your UI
  • Ensuring your code is testable, scalable and reusable
riverpod pub package
flutter_riverpod pub package
hooks_riverpod pub package

Welcome to Riverpod (anagram of Provider)!

For learning how to use Riverpod, see its documentation: >>> https://riverpod.dev <<<

Long story short:

  • Define network requests by writing a function annotated with @riverpod:

    @riverpod
    Future<String> boredSuggestion(Ref ref) async {
      final response = await http.get(
        Uri.https('boredapi.com', '/api/activity'),
      );
      final json = jsonDecode(response.body);
      return json['activity']! as String;
    }
    
  • Listen to the network request in your UI and gracefully handle loading/error states.

    class Home extends ConsumerWidget {
      @override
      Widget build(BuildContext context, WidgetRef ref) {
        final boredSuggestion = ref.watch(boredSuggestionProvider);
        // Perform a switch-case on the result to handle loading/error states
        return switch (boredSuggestion) {
          AsyncData(:final value) => Text('data: $value'),
          AsyncError(:final error) => Text('error: $error'),
          _ => const Text('loading'),
        };
      }
    }
    

Contributing

Contributions are welcome!

Here is a curated list of how you can help:

  • Report bugs and scenarios that are difficult to implement
  • Report parts of the documentation that are unclear
  • Fix typos/grammar mistakes
  • Update the documentation or add examples
  • Implement new features by making a pull-request

Sponsors

Categories

Dependencies

Dependency list 12 items

Source repository

Projects using this package