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

패키지 상세v1.0.4

power_state

의존성 주입이 있는 Flutter 상태 관리 솔루션입니다. 상태를 쉽게 관리할 수 있습니다

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
102
좋아요
14
Pub 점수
150

패키지 설치

flutter pub add power_state

패키지 개요

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

PowerState는 상태 관리를 단순화하기 위해 종속성 주입을 통합한 Flutter 상태 관리 솔루션입니다. 개발자가 애플리케이션 상태를 효율적으로 관리할 수 있도록 하며 깔끔하고 확장 가능한 코드를 촉진합니다. 내장된 종속성 주입으로 반복 코드를 줄이고 테스트 가능성을 높입니다. 이 패키지는 모든 주요 플랫폼을 지원하므로 크로스플랫폼 애플리케이션에 이상적입니다. 직관적인 API는 간편한 설정과 위젯 간의 원활한 상태 업데이트를 가능하게 합니다.

사용 사례

  • 크로스 플랫폼 앱 상태 관리
  • Flutter 앱에서의 종속성 주입
  • 복잡한 상태 로직 간소화
  • 상태를 가진 컴포넌트 테스트
  • 확장 가능한 UI 아키텍처 구축
  • 상태 처리에서 반복 코드 줄이기

주요 기능

  • 내장된 종속성 주입
  • 크로스 플랫폼 지원
  • 최소한의 보일러플레이트
  • 간편한 상태 업데이트
  • 확장 가능한 아키텍처
  • 테스트 친화적인 설계

적합한 대상

  • 통합된 DI 및 상태 관리가 필요한 개발자
  • 대규모 Flutter 애플리케이션을 개발하는 팀
  • 유지보수 가능한 상태 로직이 필요한 프로젝트
  • Flutter 초보자들이 상태 관리 배우기
  • 다중 플랫폼을 대상으로 하는 앱

고려 사항

  • 사용 가능한 문서가 제한적입니다
  • 인기 있는 대안들에 비해 커뮤니티 규모가 작음
  • 새 사용자에게는 학습 곡선이 필요할 수 있습니다
  • 생산 환경에서 아직 널리 채택되지 않음
  • 제한된 제3자 플러그인 호환성 가능성

원본 README

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

Power State is a lightweight and flexible state management library for Flutter apps. It provides a simple and easy-to-use API that helps you manage the state of your app in a clean and efficient way. With Power State, you can easily manage your app's state and update your UI in real-time.

Usage

Step:1 Create a PowerController

Create a controller class that extends PowerController. This controller class will hold your application's state and provide methods to manipulate it.

Here's an example CounterController class:

import 'package:power_state/power_state.dart';

class CounterController extends PowerController {
  int count = 1;

  increment() {
    count++;
    notifyListeners();
  }
}

Step:2 Store controller

Instantiate your controller class using PowerVault.put() method:

final CounterController controller = PowerVault.put(CounterController());

Step:3 Use PowerBuilder and PowerSelector to access your state

Use PowerBuilder to listen for changes to your state and rebuild your UI. Use PowerSelector to select a specific value from your state and rebuild only when that value changes.:

PowerBuilder<CounterController>(
  builder: (countController) {
    return Text(countController.count.toString());
  },
),

PowerSelector<CounterController>(
  selector: () => controller.selectorValue,
  builder: (countController) {
    return Text(countController.selectorValue.toString());
  },
),

Step:4 Update your state

Update your state by calling methods on your controller and calling notifyListeners() to rebuild your UI.

controller.increment();
controller.update();

You can find a Controller that is being used by another page and redirect you to it.

final CounterController countController = PowerVault.find();

Deleting a controller

If you no longer need a controller, you can delete it from PowerVault using the PowerVault.delete() method. Here's an example of deleting the CounterController:

PowerVault.delete<CounterController>();

Deleting all controller

If you no longer need controllerr, you can delete it from PowerVault using the PowerVault.clear() method. Here's an example of clear controllers:

PowerVault.clear();

Check out the example app to see Power State in action.

카테고리

소스 저장소

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

아직 데이터가 없습니다.