Star 历史趋势
rrousselGit/riverpod
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

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
riverpodpub package
flutter_riverpodpub package
hooks_riverpodpub 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:

    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 { 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

关于 About

A reactive caching and data-binding framework. Riverpod makes working with asynchronous code a breeze.
dartflutterhacktoberfestinheritedwidgetproviderriverpodservice-locatorstate-management

语言 Languages

Dart51.0%
MDX46.7%
JavaScript1.1%
TypeScript1.0%
SCSS0.1%
Shell0.0%
CSS0.0%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
389
Total Commits
峰值: 48次/周
Less
More

核心贡献者 Contributors