Git Product home page Git Product logo

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

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