eric-taix/fluid-nav-bar
A flutter fluid bottom navigation bar
前往 github 下载Fluid Navigation Bar
Many thanks to gskinner for “The vignettes” showcase presented at Flutter Interact '19 :
They created an awesome creative experience and most of the code in this package comes from
their realisation. I was really impressed by their huge work but the code, even if it was open-sourced,
was not usable as it. So I did some refactoring for maintainability, I extracted some
fields to be able to adapt and skin the widget according to our design and decided to share it.Enjoy
Basic Usage
FluidNavBar
is simply a bottom navigation bar but with a very cool and fluid effect while
animating the transition between an active button to another one.
The example below shows you the minimal code to use the widget.
@override
Widget build(context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Color(0xFF75B7E1),
extendBody: true,
body: _theBody,
bottomNavigationBar: FluidNavBar( // (1)
icons: [ // (2)
FluidNavBarIcon(svgPath: "assets/home.svg"), // (3)
FluidNavBarIcon(svgPath: "assets/bookmark.svg"),
],
onChange: _handleNavigationChange, // (4)
),
),
);
}
(1) Create an instance of FluidNavBar
(2) Set the icons, of type FluidNavBarIcon
, to display in the navigation bar
(3) FluidNavBarIcon
supports SVG asset or IconData
(4) Set the callback to react when the user tap an icon (the callback parameter contains the icon’s index)
When defining FluidNavBarIcon
you can provide an SVG asset or an IconData
. Use the field svgPath
for an SVG or
the field icon
for an IconData
.
Example:
FluidNavBar(
icons: [
FluidNavBarIcon(
svgPath: "assets/home.svg",
backgroundColor: Color(0xFF4285F4),
extras: {"label": "home"}),
FluidNavBarIcon(
icon: Icons.bookmark_border,
backgroundColor: Color(0xFFEC4134),
extras: {"label": "bookmark"}),
],
Note: For backward compatibility (previous to v1.2.0) you can still use the field iconPath
to set
the SVG asset to use (this is the same behaviour of svgPath
). But this field has been deprecated and will
be removed in a future version.
How To Style
FluidNavBar
comes with a default set of styles which are directly inherited from the gskinner showcase.
You can override different properties to adapt the fluid navigation bar to your current design:
- the bar background color (
Colors.white
by default) - the icon background color (the same color as the bar background color by default)
- the icon foreground color when it’s selected (
Colors.black
by default) - the icon foreground color when it’s unselected (
Colors.grey
by default)
Global Styles
The easiest way is to define one or more properties in a FluidNavBatStyle
and set this instance
in the style
property of the FluidNavBar
:
FluidNavBar(
icons: [
FluidNavBarIcon(svgPath: "assets/home.svg"),
FluidNavBarIcon(svgPath: "assets/bookmark.svg"),
],
onChange: _handleNavigationChange,
style: FluidNavBarStyle(
barBackgroundColor: Color(0xFFFB5C66),
iconBackgroundColor: Colors.white,
iconSelectedForegroundColor: Color(0xFFFB5C66),
iconUnselectedForegroundColor: Colors.black
),
)
is displayed as:
Properties:
Property | Description |
---|---|
barBackgroundColor |
Set the background color of the bar |
iconBackgroundColor |
Set the background color for all icons |
iconSelectedForegroundColor |
Set the foreground color for the selected icon |
iconUnselectedForegroundColor |
Set the background color for all unselected icons |
Local Styles
You can also define some specific styles per icon, by using optional parameters of FluidNavBarIcon
:
FluidNavBar(
icons: [
FluidNavBarIcon(svgPath: "assets/home.svg", backgroundColor: Color(0xFF4285F4)),
FluidNavBarIcon(svgPath: "assets/bookmark.svg", backgroundColor: Color(0xFFEC4134)),
FluidNavBarIcon(svgPath: "assets/partner.svg", backgroundColor: Color(0xFFFCBA02)),
FluidNavBarIcon(svgPath: "assets/conference.svg", backgroundColor: Color(0xFF34A950)),
],
onChange: _handleNavigationChange,
style: FluidNavBarStyle(
iconUnselectedForegroundColor: Colors.white
)
),
is displayed as
Note: In this example I used also a global style for the foreground color of unselected icons, as I don’t want
to set the same color for all icons
Properties:
Property | Description |
---|---|
backgroundColor |
Set the background color of the icon |
selectedForegroundColor |
Set the foreground color for a selected icon |
unselectedForegroundColor |
Set the foreground color for all unselected icons |
Styles Priorities
You can define global styles, local styles, both or no style at all!
To define the proper style to apply it tries, for each style, to resolve its value in the following order:
1- local style
2- global style
3- default value
when a value is resolved then it applies it to the widget.
For example if you set the global style iconBackgroundColor
to Colors.red
and you also
set the local style backgroundColor
to Colors.green
for an icon, then it will use the green color
as the local style will be resolved before the global one.
Other options
There are also few options, you can play with. They are global options and accessible throw FluidNaBar
fields.
Property | Description |
---|---|
animationFactor |
Set the factor to boost or slowdown animation. The default value is 1.0. If you use a value < 1 then the animation will be faster, if you use a value > 1 the animation will be slower |
scaleFactor |
Define the factor used by the animation to zoom the selected icon. The default value is 1.2. If the value is > 1 then it is a zoom-in, if you use a value < 1 then it is zoom-out |
defaultIndex |
Set to change selected item on start of the application. By default set to 0. |
For an animationFactor
of 2.0 (slower) and a scaleFactor
of 2.0 (a zoom-in bigger than the default one), the result is:
Contributions
Feel free to create an issue if you find a bug or if you need new features. Of course PRs are welcome!
If you want to contact me on Twitter: @etaix
Contributors
Many thanks to these contributors:
- Umair M
- Dmitriy Govorov
- Christos Tsortanidis
- Dorbmon
![](/images/banner-woo.jpg)
与 eric-taix/fluid-nav-bar 相关优秀项目推荐下载
AppFlowy
47859
AppFlowy is an open-source alternative to Notion. You are in charge of your data and customizations. Built with Flutter and Rust.
localsend
33797
An open-source cross-platform alternative to AirDrop
spotube
23772
🎧 Open source Spotify client that doesn't require Premium nor uses Electron! Available for both desktop & mobile!
revanced-manager
15035
💊 Application to use ReVanced on Android
gsy_github_app_flutter
14559
Flutter 超完整的开源项目,功能丰富,适合学习和日常使用。GSYGithubApp系列的优势:我们目前已经拥有Flutter、Weex、ReactNative、kotlin 四个版本。 功能齐全,项目框架内技术涉及面广,完成度高,持续维护,配套文章,适合全面学习,对比参考。跨平台的开源Github客户端App,更好的体验,更丰富的功能,旨在更好的日常管理和维护个人Github,提供更好更方便的驾车体验Σ( ̄。 ̄ノ)ノ。同款Weex版本 : https://github.com/CarGuo/GSYGithubAppWeex 、同款React Native版本 : https://github.com/CarGuo/GSYGithubApp 、原生 kotlin 版本 https://github.com/CarGuo/GSYGithubAppKotlin
dio
12249
A powerful HTTP client for Dart and Flutter, which supports global settings, Interceptors, FormData, aborting and canceling a request, files uploading and downloading, requests timeout, custom adapters, etc.
gopeed
11832
A modern download manager that supports all platforms. Built with Golang and Flutter.
bloc
11441
A predictable state management library that helps implement the BLoC design pattern
getx
9899
Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
flame
8846
A Flutter based game engine.
flutter_deer
7595
🦌 Flutter 练习项目(包括集成测试、可访问性测试)。内含完整UI设计图,更贴近真实项目的练习。Flutter practice project (including integration testing and accessibility testing). Contains complete UI design drawings for a more realistic practice project.
fish-redux
7343
An assembled flutter application framework.
hiddify-next
7232
Multi-platform auto-proxy client, supporting Sing-box, X-ray, TUIC, Hysteria, Reality, Trojan, SSH etc. It’s an open-source, secure and ad-free.
ente
6686
Fully open source, End to End Encrypted alternative to Google Photos and Apple Photos
fl_chart
6451
FL Chart is a highly customizable Flutter chart library that supports Line Chart, Bar Chart, Pie Chart, Scatter Chart, and Radar Chart.
pixez-flutter
6360
一个支持免代理直连及查看动图的第三方Pixiv flutter客户端
Flutter-Responsive-Admin-Panel-or-Dashboard
6355
Responsive Admin Panel or Dashboard using Flutter
aidea
6021
AIdea 是一款支持 GPT 以及国产大语言模型通义千问、文心一言等,支持 Stable Diffusion 文生图、图生图、 SDXL1.0、超分辨率、图片上色的全能型 APP。
riverpod
5828
A reactive caching and data-binding framework. Riverpod makes working with asynchronous code a breeze.
pikapika
5463
美观易用且无广告的漫画和游戏客户端,同时支持MacOS,Windows,Android,iOS。