패키지, 저장소 및 앱 카테고리 검색

패키지 상세v4.0.7

riverpod_annotation

riverpod_generator용 주석을 노출하는 패키지

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
142만
좋아요
181
Pub 점수
130

패키지 설치

flutter pub add riverpod_annotation

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

riverpod_annotation은 Flutter 애플리케이션에서 Riverpod 제공자를 생성하는 것을 간소화하기 위한 코드 생성 패키지입니다. riverpod_generator와 함께 작동하여 봐일러플레이트 코드를 자동으로 생성함으로써 수작업과 잠재적인 오류를 줄여줍니다. 간단한 어노테이션을 사용하면 개발자들이 상태 관리 로직을 더 효율적으로 정의할 수 있어 코드의 가독성과 유지보수성을 향상시킬 수 있습니다. 이 패키지는 모든 주요 플랫폼을 지원하므로 크로스플랫폼 개발에 이상적입니다.

사용 사례

  • 공급자 생성 자동화
  • 상태 관리 설정 간소화
  • Riverpod 코드에서 반복 코드 줄이기
  • 형 안전한 종속성 활성화
  • 대규모 앱 아키텍처 지원

주요 기능

  • 공급자 정의를 위한 어노테이션
  • riverpod_generator와의 통합
  • 타입 안전성 강제
  • 크로스 플랫폼 호환성
  • 최소의 런타임 오버헤드

적합한 대상

  • Riverpod를 사용하는 Flutter 개발자
  • 코드 유지보수를 우선시하는 팀
  • 확장 가능한 상태 관리가 필요한 프로젝트
  • 보일러플레이트를 줄이려는 개발자
  • 다중 플랫폼을 대상으로 하는 앱

고려 사항

  • riverpod_generator 포함이 필요합니다
  • 코드 생성을 위해 build_runner가 필요합니다
  • 빌드 시간을 약간 증가시킬 수 있습니다
  • 런타임 제공자 생성에 적합하지 않음
  • 정확한 주석 사용에 의존

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

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

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

카테고리

의존성

의존성 목록 2 개

소스 저장소

이 패키지를 사용하는 프로젝트