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

패키지 상세v0.7.1

flutter_redux_navigation

Flutter의 redux 라이브러리용 간단한 반응형 네비게이션 미들웨어입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
443
좋아요
13
Pub 점수
160

패키지 설치

flutter pub add flutter_redux_navigation

패키지 개요

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

Redux를 사용하여 Flutter 앱에서 반응형 네비게이션을 가능하게 하는 가벼운 미들웨어입니다. 이는 네비게이션 상태를 Redux 스토어와 동기화하여 앱 상태 변경에 따라 경로를 선언적이고 반응적으로 관리할 수 있도록 합니다. 이 패키지는 네비게이션 로직을 Redux 흐름에 통합함으로써 봉쇄 코드를 줄이고 테스트 용이성을 향상시킵니다. 모든 주요 플랫폼을 지원하며 Flutter의 Redux 생태계와 원활하게 작동합니다.

사용 사례

  • 선언적 라우트 관리
  • 상태 기반 반응형 탐색
  • 컴포넌트 간 동기화 탐색
  • 내비게이션 로직 테스트
  • 스테이트 기반 라우팅의 단순화

주요 기능

  • Redux 스토어와의 통합
  • 반응형 라우트 업데이트
  • 최소한의 보일러플레이트
  • 크로스 플랫폼 지원
  • 간편한 테스트
  • 상태 기반 네비게이션

적합한 대상

  • Redux 기반의 Flutter 앱
  • 상태에 따라 달라지는 탐색이 필요한 앱
  • 명확한 탐색 패턴을 찾는 개발자
  • 반응형 상태 관리를 사용하는 팀
  • 예측 가능한 탐색 흐름이 필요한 프로젝트

고려 사항

  • Redux 설정이 필요합니다
  • Redux 아키텍처에 한정
  • 간단한 앱에 복잡성을 추가할 수 있음
  • 비-Redux 프로젝트에는 적합하지 않습니다
  • 이동을 위해 주의 깊은 상태 설계가 필요합니다

원본 README

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

Build Status codecov

Flutter Navigation for redux

Navigation Middleware for Flutter's redux library.

Basic classes that enables page navigation through by utilizing Redux Store middleware facility.

This package is built to work with Redux.dart 4.0.0+.

Redux Middleware

  • NavigationMiddleware<T> - The Middleware that reacts to NavigateToActions.

Examples

Take a look in the examples directory.

How to setup navigation

import 'package:flutter/material.dart';
import 'package:redux/redux.dart';

class AppState {
  final String name;
  
  const AppState(this.name);
  
  factory AppState.initial() => AppState(null);
  factory AppState.changeName(String name) => AppState(name);
}

class AppNameChangedAction {
  final String name;

  AppNameChangedAction(this.name);
}

AppState _onAppNameChanged(AppState state, AppNameChangedAction action) =>
    state.changeName(action.name);

final appReducer = combineReducers<AppState>([
  TypedReducer<AppState, AppNameChangedAction>(_onAppNameChanged),
]);


final store = new Store<AppState>(combineReducers<AppState>([appReducer]),
    initialState: AppState.initial(),
    middleware: [
      NavigationMiddleware<AppState>(),
    ]);

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return StoreProvider<AppState>(
        store: store,
        child: MaterialApp(
          title: 'My App',
          navigatorKey: NavigatorHolder.navigatorKey,
        )
    );
  }
}

void main() => runApp(MyApp());

How to navigate

Let's say you wish to navigate from a LoginPage to some dashboard page, you only need to dispatch a NavigateToAction.replace action with the appropriate path, which is registered to the dashboard page.

import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';

class LoginPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => LoginPageState();
}

class LoginPageState extends State<LoginPage> {
  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, AuthBloc>(
      converter: (store) {
        return store;
      },
      builder: (BuildContext context, Store<AppState> store) {
        return Scaffold(body: Builder(
          builder: (BuildContext context) {
            return Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                RaisedButton(
                onPressed: () {
                  store.dispatch(NavigateToAction.replace('/dashboard'));
                },
                child: Text('Login'),
              )
              ],
            );
          },
        ));
      },
    );
  }
}

How to use pre and post navigation hooks

Let's use the same example as before, but now let's assume that you want to start a loader whilst navigating to the dashboard and stop it once you have navigated.

import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';

class LoginPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => LoginPageState();
}

class LoginPageState extends State<LoginPage> {
  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, AuthBloc>(
      converter: (store) {
        return store;
      },
      builder: (BuildContext context, Store<AppState> store) {
        return Scaffold(body: Builder(
          builder: (BuildContext context) {
            return Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                RaisedButton(
                onPressed: () {
                  store.dispatch(
                    NavigateToAction.replace(
                      '/dashboard',
                      preNavigation: () => store.dispatch(StartLoadingAction()),
                      postNavigation: () => store.dispatch(StopLoadingAction()),
                    ),
                  );
                },
                child: Text('Login'),
              )
              ],
            );
          },
        ));
      },
    );
  }
}

카테고리

의존성

의존성 목록 1 개

소스 저장소

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