Routemaster는 웹, 모바일, 데스크톱 플랫폼을 아우르는 Flutter 애플리케이션용 가볍고 사용하기 쉬운 라우팅 솔루션입니다. URL 기반 네비게이션을 지원하며 중첩 라우트와 탭 기반 네비게이션도 가능하여 복잡한 라우트 관리를 간소화합니다. 단순성과 개발자 경험을 최우선으로 고려해 설계되었으며, 기존의 Flutter 프로젝트에 원활하게 통합됩니다. 깔끔한 API를 통해 라우트 전환, 동적 매개변수, 딥링크를 직관적으로 처리할 수 있습니다. 반복 코드 없이 구조화된 네비게이션을 필요로 하는 앱에 이상적입니다.
사용 사례
동적 콘텐츠를 갖춘 단일 페이지 애플리케이션
모바일 및 웹에서의 멀티탭 인터페이스
복잡한 UI에서 중첩된 라우트 구조
딥링크 및 URL 동기화
일관된 라우팅이 필요한 크로스 플랫폼 앱
최소 설정으로 간단한 탐색
주요 기능
URL 기반 라우팅
중첩 및 탭 루트 지원
최소한의 보일러플레이트
크로스 플랫폼 호환성
기존 Flutter 앱과의 간편한 통합
동적 경로 매개변수
적합한 대상
크로스 플랫폼 플러터 앱을 개발하는 개발자
클린하고 유지보수 가능한 라우팅 로직을 우선시하는 팀
딥링크 또는 SPA 유사 동작이 필요한 프로젝트
복잡한 탐색 계층을 가진 앱
직관적인 라우팅 솔루션을 찾는 초보자
고려 사항
Flutter의 네이티브 탐색 모델에 제한됨
고급 사용 사례를 위해 추가 상태 관리가 필요할 수 있습니다
표준 패턴을 초과하는 고도로 커스터마이즈된 라우팅 동작에는 적합하지 않음
경로 가드 또는 인증 리디렉션에 내장된 지원 없음
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Routemaster
Hello! Routemaster is an easy-to-use router for Flutter, which wraps over Flutter's Router API.
Features
Simple declarative mapping from URLs to pages
Easy-to-use API: just Routemaster.of(context).push('/page')
Really easy nested navigation support for tabs
Multiple route maps: for example one for a logged in user, another for logged out
Observers to easily listen to route changes
Covered by over 250 unit, widget and integration tests
Here's the entire routing setup needed for an app featuring tabs and pushed routes:
Routemaster generates pages based on the current path. This is the key concept of its path-base routing. Path structure matters.
It uses the path to decide where a page should be pushed. This means the path needs to match your intended page hierarchy.
For example:
'/tabs': (route) => TabPage(child: HomePage(), paths: ['one', 'two']),
// First tab default page'/tabs/one': (route) => MaterialPage(child: TabOnePage()),
// Second tab default page'/tabs/two': (route) => MaterialPage(child: TabTwoPage()),
// Second tab sub-page: will be displayed in the 2nd tab because it// starts with '/tabs/two''/tabs/two/subpage': (route) => MaterialPage(child: TabTwoPage()),
// Not a tab page: will not be displayed in in a tab// because the path doesn't start with '/tabs/one' or '/tabs/two''/tabs/notInATab': (route) => MaterialPage(child: NotTabPage()),
Any child paths that begin with /tabs/one or /tabs/two will be pushed into the correct tab.
When navigating to /tabs/two/subpage, the TabPage will be asked "hey, do you know how to handle this path?" and it'll go "sure! it starts with /tabs/two, so it goes in my second tab".
However, navigating to /tabs/notInATab will not be displayed in a tab, but pushed on top of the tab bar.
TabPage will be all "yeah sorry, no idea what to do with that, doesn't match any of my tab paths" and its parent will be asked to hande it.