Giter Site home page Giter Site logo

doug-orchard / riverpod Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rrousselgit/riverpod

0.0 0.0 0.0 27.03 MB

A simple way to access state while robust and testable.

Home Page: https://riverpod.dev

License: MIT License

Shell 0.01% JavaScript 1.20% Dart 64.00% TypeScript 1.21% CSS 0.03% SCSS 0.18% MDX 33.38%

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 scenearios, 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),
        );
      }
    }

See the FAQ if you have questions about what this means for provider.

Contributing

Contributions are welcomed!

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 / add examples
  • Implement new features by making a pull-request

Sponsors

riverpod's People

Contributors

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