Giter Site home page Giter Site logo

drown0315 / riverpod Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rrousselgit/riverpod

0.0 0.0 0.0 29.09 MB

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

Home Page: https://riverpod.dev

License: MIT License

Shell 0.01% JavaScript 1.65% Dart 53.40% TypeScript 1.41% CSS 0.02% SCSS 0.16% MDX 43.34%

riverpod's Introduction

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(BoredSuggestionRef ref) async {
      final response = await http.get(
        Uri.https('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 boredSuggestion.when(
          loading: () => Text('loading'),
          error: (error, stackTrace) => Text('error: $error'),
          data: (data) => Text(data),
        );
      }
    }

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

riverpod's People

Contributors

ahmedlsayed9 avatar alexhartford avatar aspiiire avatar bytes7bytes7 avatar chunghha avatar coyksdev avatar dependabot[bot] avatar freemansoft avatar giandifra avatar gitgud31 avatar jaichangpark avatar jpdesarrolloapp avatar julienlebren avatar k9i-0 avatar leonardorosaa avatar lucavenir avatar manavb2214 avatar marcoredz avatar mono0926 avatar papihack avatar rcjuancarlosuwu avatar robertbrunhage avatar rrousselgit avatar tatsuyafujisaki avatar tbm98 avatar timwhiting avatar toshi-kuji avatar utamori avatar valentinvignal avatar yiss avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.