flutter_riverpod
一個反應式快取與資料繫結框架。Riverpod 讓處理非同步程式碼變得輕鬆自在。
一個反應式快取與資料繫結框架。Riverpod 讓處理非同步程式碼變得輕鬆愉快。
以下為英文專案原文快照,最新內容請造訪 GitHub。
A reactive caching and data-binding framework. https://riverpod.dev Riverpod makes working with asynchronous code a breeze by:
| riverpod | |
|---|---|
| flutter_riverpod | |
| hooks_riverpod |
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'),
};
}
}
Contributions are welcome!
Here is a curated list of how you can help:
一個反應式快取與資料繫結框架。Riverpod 讓處理非同步程式碼變得輕鬆自在。
一個反應式快取與資料繫結框架。Riverpod 讓處理非同步程式碼變得輕鬆自在。
一個反應式快取與資料繫結框架。Riverpod 讓處理非同步程式碼變得輕鬆自在。
一個為 riverpod_generator 暴露註解的套件
Riverpod 的程式碼產生器。這不僅簡化語法,還增強功能,例如支援狀態熱重新載入。
先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗