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

패키지 상세v1.0.0

hydrated_triple

스토어 상태를 자동으로 지속 및 복원하는 믹스인입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
160
좋아요
0
Pub 점수
145

패키지 설치

flutter pub add hydrated_triple

패키지 개요

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

HydratedTriple은 앱 재시작 시 스토어 상태를 자동으로 지속하고 복원함으로써 상태 관리를 단순화하는 Flutter/Dart 패키지입니다. Triple 패턴 위에 구축되어 있으며, Riverpod 또는 Provider와 원활하게 통합되어 사용자 설정, 로그인 상태, 폼 입력과 같은 데이터를 수동 직렬화 없이 유지할 수 있게 해줍니다. 믹스인은 로컬 저장소(예: SharedPreferences)에 상태를 저장하고 앱을 시작할 때 다시 불러오는 작업을 처리하여 반복 코드를 줄이고 사용자 경험을 향상시킵니다. 최소한의 설정으로 신뢰성 있는 상태 지속이 필요한 앱에 적합합니다.

사용 사례

  • 사용자 선호 사항 유지
  • 재시작 후 로그인 상태 복원
  • 양식 데이터를 일시적으로 저장합니다
  • 세션 간에 앱 설정 유지
  • 오프라인 우선 시나리오 처리

주요 기능

  • 자동 상태 유지
  • Riverpod/Provider와의 원활한 통합
  • 여러 플랫폼을 지원합니다
  • 최소한의 보일러플레이트
  • 내장 시리얼라이제이션
  • 크로스 플랫폼 호환성

적합한 대상

  • 지속 상태가 필요한 앱
  • 트리플 패턴을 사용하는 개발자
  • 오프라인 기능을 갖춘 프로젝트
  • 개발자 생산성을 우선시하는 팀
  • 최소 코드로 상태 관리

고려 사항

  • 상태 객체의 올바른 직렬화가 필요합니다
  • 앱 시작 시간이 약간 증가할 수 있습니다
  • 크거나 자주 변경되는 상태에 적합하지 않음
  • 사용자 정의 로직이 추가되지 않는 한 간단한 상태 구조에만 제한됨
  • 기본 상태 관리 솔루션에 의존함

원본 README

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

Triple - Segmented State Pattern


Logo Logo

Welcome to Triple! Design Pattern for State Management.

· Report Bug · Request Feature



Table of Contents
  1. About The Project
  2. Usage
    1. Installation
    2. How to use?
  3. Contributing
  4. Contact
  5. Contributors


:memo: About The Project

What is Triple?

Triple is a nickname to SSP (Segmented State Standard). Some packages were created to make it easier for developers to start using the standard. We'll call it an extension.

Segmented State Pattern (SSP)

When we talk about a single flow state, we end up solving architecture problems early, as we will have only one data flow for each state.

In addition to the maintainability and to the ease of use architecture, we also have the possibility of increasing this flow with other standards such as the Observer, which gives reactivity to the component when it is modified, and Memento, which makes it possible to revert or redo this state.

A beautiful example of a pattern with a single flow is BLoC, giving reactivity to a state allowing all transformations in that flow. This (although complicated for some), consolidates very well in the architecture of a project, even the limits of this practice are beneficial for not allowing the developer to resort to other solutions for the architecture and the standard for its resource.

There are other ways to promote reactivity in a property instead of the entire object, such as MobX's Observable and Flutter's ValueNotifier, and that gives us a lot of choices. However, we lose some important architecture limits, which can put in check the project maintenance in the future. Therefore, it needs a standard to force limits on the individual reactivity of each property and thereby improve the maintainability of the components responsible for managing the states of the application.

Triple is a nickname to SSP (Segmented State Standard). Some packages were created to make it easier for developers to start using the standard. We'll call it an extension.


This project is distributed under the MIT License. See LICENSE.txt for more information.


✨ Usage

The SSP segments the state into 3 reactive parts, the state value (state), the error object (error), and the state loading action (loading).

These segments are observed in a listener or separate listeners. They can also be combined to obtain a new segment, always starting from the 3 main segments.

Installation

Dependencies

add the following dependencies to your pubspec.yaml file:

dependencies:
  flutter_triple: ^1.3.0
Import

Import the package in your code with:

import 'package:flutter_triple/flutter_triple.dart';

How to use?

Create a Store

Create a class that extends NotifierStore<Error, State>. The first type is the type of the error, the second is the type of the state.

class CounterStore extends NotifierStore<Exception, int> {
  CounterStore() : super(0);

  void increment() => update(state + 1);
  void decrement() => update(state - 1);
}
Consume with Listeners, Builders and Consumers

Consume the store with scopes ScopedBuilder, ScopedListener and ScopedConsumer.


class CounterPage extends StatefulWidget {
  @override
  _CounterPageState createState() => _CounterPageState();
}

class _CounterPageState extends State<CounterPage> {
  final store = CounterStore();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Counter'),
      ),
      body: ScopedBuilder<CounterStore, Exception, int>(
        store: store,
        onLoading: (context) => Center(child: CircularProgressIndicator()),
        onError: (context, error) => Center(child: Text(error.toString())),
        onState: (context, state) => Center(
          child: Text(
            '$state',
            style: Theme.of(context).textTheme.headline4,
          ),
        ),
      ),
      floatingActionButton: Row(
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            FloatingActionButton(
              onPressed: store.decrement,
              tooltip: 'Decrement',
              child: Icon(Icons.remove),
            ),
            SizedBox(width: 5),
            FloatingActionButton(
              onPressed: store.increment,
              tooltip: 'Increment',
              child: Icon(Icons.add),
            ),
          ],
        ),
    );
  }
}

🧑‍💻 Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the appropriate tag. Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Remember to include a tag, and to follow Conventional Commits and Semantic Versioning when uploading your commit and/or creating the issue.

(back to top)

💬 Contact

Flutterando Community

(back to top)


👥 Contributors

(back to top)

🛠️ Maintaned by


This fork version is maintained by Flutterando.

카테고리

의존성

의존성 목록 2 개

소스 저장소

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

아직 데이터가 없습니다.