Flutter용으로 매우 사용자 정의가 가능한 지속적인 하단 탐색 바로, 최대 20개의 서로 다른 스타일을 지원합니다. Android, iOS, Web, macOS, Windows, Linux 등 모든 플랫폼에서 일관된 네비게이션 경험을 제공합니다. 색상, 아이콘, 레이블 및 애니메이션에 대한 광범위한 사용자 정의 옵션을 통해 개발자가 일관성 있고 시각적으로 매력적인 하단 네비게이션을 쉽게 구현할 수 있습니다. 사용자 상호작용 중에도 항상 표시되는 신뢰할 수 있고 재사용 가능한 네비게이션 바가 필요한 앱에 적합합니다.
사용 사례
모바일 앱 탐색
크로스 플랫폼 앱
대시보드 인터페이스
전자상거래 앱
다중 화면 애플리케이션
주요 기능
최대 20개의 내장 스타일
사용자 지정 가능한 색상 및 아이콘
지속적인 가시성
다수의 플랫폼을 지원합니다
애니메이션 지원
pub를 통한 간편한 통합
적합한 대상
모바일 중심 앱을 개발하는 개발자
디자인 중심의 UI 구현
일관된 탐색이 필요한 앱
다중 플랫폼 호환성을 우선시하는 팀
최소한의 보일러플레이트가 필요한 프로젝트
고려 사항
복잡한 레이아웃을 위해 추가 스타일링이 필요할 수 있습니다
하단 배치만 가능
일부 스타일은 모든 디자인 시스템에 적합하지 않을 수 있습니다
과도한 사용자 정의로 인한 성능 영향
상태 관리에 주의 깊게 대응해야 합니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Persistent Bottom Navigation Bar
A persistent/static bottom navigation bar for Flutter.
NOTE: Those migrating from pre 6.0.0 version should check the latest readme and changelog as there are many breaking changes introduced in the latest update.
Styles
Style15
Style16
Style1
Style9
Style7
Style10
Style12
Style13
Style3
Style6
Neumorphic
Neumorphic without subtitle
Note: These do not include all style variations
Features
Highly customizable persistent bottom navigation bar.
Ability to push new screens with or without bottom navigation bar.
20 styles for the bottom navigation bar.
Includes functions for pushing screen with or without the bottom navigation bar i.e. pushNewScreen() and pushNewScreenWithRouteSettings().
Based on flutter's Cupertino(iOS) bottom navigation bar.
Can be translucent for a particular tab.
Custom styling for the navigation bar. Click here for more information.
The main widget then to be declared is PersistentTabView. NOTE: This widget includes SCAFFOLD (based on CupertinoTabScaffold), so no need to declare it. Following is an example for demonstration purposes:
classMyAppextendsStatelessWidget{
constMyApp({Key key}) : super(key: key);
@overrideWidgetbuild(BuildContext context) {
returnPersistentTabView(
context,
controller: _controller,
screens: _buildScreens(),
items: _navBarsItems(),
handleAndroidBackButtonPress: true, // Default is true.
resizeToAvoidBottomInset: true, // This needs to be true if you want to move up the screen on a non-scrollable screen when keyboard appears. Default is true.
stateManagement: true, // Default is true.
hideNavigationBarWhenKeyboardAppears: true,
popBehaviorOnSelectedNavBarItemPress: PopActionScreensType.all,
padding: constEdgeInsets.only(top: 8),
backgroundColor: Colors.grey.shade900,
isVisible: true,
animationSettings: constNavBarAnimationSettings(
navBarItemAnimation: ItemAnimationSettings( // Navigation Bar's items animation properties.
duration: Duration(milliseconds: 400),
curve: Curves.ease,
),
screenTransitionAnimation: ScreenTransitionAnimationSettings( // Screen transition animation on change of selected tab.
animateTabTransition: true,
duration: Duration(milliseconds: 200),
screenTransitionAnimationType: ScreenTransitionAnimationType.fadeIn,
),
),
confineToSafeArea: true,
navBarHeight: kBottomNavigationBarHeight,
navBarStyle: _navBarStyle, // Choose the nav bar style with this property
);
}
}
Note: You still can use regular Navigator functions like 'pushNamed' but be sure to check the argument routeAndNavigatorSettings your PersistentBottomNavBarItem for route settings and some other navigator related properties
To push a new screen, use the following functions to control the visibility of bottom navigation bar on a particular screen. You can use your own logic to implement platform-specific behavior. One of the solutions could be to use the property withNavBar and toggle it according to the Platform.
In platform-specific behavior, while pushing a new screen, on Android it will push the screen WITHOUT the bottom navigation bar but on iOS it will persist the bottom navigation bar. This is the default behavior specified by each platform.
Pop all screens until the first screen on the selected tab
PersistentNavBarNavigator.popUntilFirstScreenOnSelectedTabScreen(
context,
routeName: "/", //If you haven't defined a routeName for the first screen of the selected tab then don't use the optional property `routeName`. Otherwise it may not work as intended
);
Some Useful Tips
Pop to any screen in the navigation graph for a given tab:
To push bottom sheet on top of the Navigation Bar, use showModalBottomScreen and set it's property useRootNavigator to true. See example project for an illustration.
Custom Navigation Bar Styling
If you want to have your own style for the navigation bar, follow these steps:
Declare your custom widget. Please keep in mind that you will have to handle the function onSelectedItem and the integer selectedIndex yourself to maintain full functionality. Also please note that you can define your own model for the navigation bar item instead of the provided PersistentBottomNavBarItem. See this example below for better understanding:
In the main PersistentTabView widget, set the navBarStyle property as NavBarStyle.custom and pass on the custom widget you just created in the customWidget property like this:
NOTE: In the 'onSelected' function of the customWidget, don't forgot to change the index of the controller
Done! As we can see, some of the other properties like iconSize, items are not required here so you can skip those properties. To control the bottom padding of the screen, use bottomScreenPadding. If you give too much bottomScreenPadding but less height in the custom widget or vice versa, layout issues might appear.
Animated Icons
Animated icons are now supported in PersistentBottomNavBarItem. You will need to define and use an AnimationController and Animation<double> for it to work. Following is an example.