搜索插件、代码仓与 APP 分类

bottom_bar 封面
插件详情v2.0.5

bottom_bar

底部栏有助于创建一个经过优化的底部导航栏,并带有精美的动画效果

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1400
喜欢数
137
Pub 分数
160

安装插件

flutter pub add bottom_bar

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Bottom Bar 是一个 Flutter 包,可帮助开发者创建优化且视觉上吸引人的底部导航栏,并带有流畅的动画效果。专为跨平台使用设计,支持 Android、iOS、Web、macOS、Windows 和 Linux。该包通过可自定义的过渡效果、响应式设计以及内置的无障碍功能,简化了底部导航的实现。它通过在不同设备上提供直观的导航模式,提升了用户体验。非常适合需要持久底部导航且具有现代美学的应用程序。

适合场景

  • 移动应用导航
  • Web 应用程序仪表板
  • 跨平台桌面应用
  • 增强的用户界面设计
  • 响应式导航布局

主要特点

  • 流畅的动画过渡
  • 可自定义外观
  • 跨平台兼容性
  • 无障碍支持
  • 响应式设计集成

适合对象

  • 开发移动或网页应用的开发者
  • 注重设计的UI实现
  • 需要一致导航的应用
  • 注重动画质量的团队
  • 针对多个平台的项目

使用建议

  • 需要 Flutter SDK 设置
  • 超出基本样式的定制功能有限
  • 可能需要额外的状态管理
  • 不适合复杂的标签结构
  • 依赖外部仓库获取更新

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Bottom Bar

Bottom bar helps create an optimized bottom navigation bar with beautiful animations.

Bottom Bar

Content

Installation

Add bottom_bar to pubspec.yaml

dependencies:
  bottom_bar: ^2.0.5

Breaking Changes

  • darkActiveColor is removed to simplify the api. Instead, use PlatformBrightness to check dark mode and adjust the color accordingly

Usage

Import the Package

import 'package:bottom_bar/bottom_bar.dart';

Example

  int _currentPage = 0;
  final _pageController = PageController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PageView(
        controller: _pageController,
        children: [
          Container(color: Colors.blue),
          Container(color: Colors.red),
          Container(color: Colors.greenAccent.shade700),
          Container(color: Colors.orange),
        ],
        onPageChanged: (index) {
          // Use a better state management solution
          // setState is used for simplicity
          setState(() => _currentPage = index);
        },
      ),
      bottomNavigationBar: BottomBar(
        selectedIndex: _currentPage,
        onTap: (int index) {
          _pageController.jumpToPage(index);
          setState(() => _currentPage = index);
        },
        items: <BottomBarItem>[
          BottomBarItem(
            icon: Icon(Icons.home),
            title: Text('Home'),
            activeColor: Colors.blue,
          ),
          BottomBarItem(
            icon: Icon(Icons.favorite),
            title: Text('Favorites'),
            activeColor: Colors.red,
          ),
          BottomBarItem(
            icon: Icon(Icons.person),
            title: Text('Account'),
            activeColor: Colors.greenAccent.shade700,
          ),
          BottomBarItem(
            icon: Icon(Icons.settings),
            title: Text('Settings'),
            activeColor: Colors.orange,
          ),
        ],
      ),
    );
  }

Parameters

BottomBar

Creates a BottomBar that displays a list of BottomBarItem
Required:
Optional:
  • backgroundColor - Background Color of BottomBar
  • height - Height of BottomBar
  • padding - Padding of BottomBar container
  • mainAxisAlignment - Describes how BottomBarItems are horizontally laid out
  • curve - Curve of animation
  • duration - Duration of animation
  • border - Border of BottomBarItem's background color
  • boxShadow - BoxShadow of BottomBar
  • itemPadding - Padding of BottomBarItem's background color
  • textStyle - TextStyle of title widget
  • showActiveBackgroundColor - Shows the background color of a selected BottomBarItem if set to true

BottomBarItem

Contains information about the item that BottomBar has to display
Required:
  • icon - Icon of BottomBarItem
  • title - Title of BottomBarItem (Typically a Text widget)
  • activeColor - Primary color of a selected BottomBarItem
Optional:
  • activeIconColor - Icon color of a selected BottomBarItem
  • activeTitleColor - Text color of a selected BottomBarItem
  • backgroundColorOpacity - Opacity of a selected BottomBarItem background color (Defaults to 15%)
  • inactiveIcon- Icon to display when BottomBarItem is not active
  • inactiveColor - Primary color of BottomBarItem when it is NOT selected

FAQ

My phone's notch is overlapping with BottomBar. How do I fix this?
  • Simply wrap BottomBar with a SafeArea widget.
How do I change the overall color of BottomBarItem when in dark mode?
  @override
  Widget build(BuildContext context) {
    bool isDarkMode = MediaQuery.of(context).platformBrightness == Brightness.dark;

    BottomBarItem(
      activeColor: isDarkMode ? Colors.orange : Colors.blue, // Is dark mode true? (Yes -> Colors.orange | No -> Colors.blue)
    ),
  }

Community Support

If you have any suggestions or issues, feel free to open an issue

If you would like to contribute, feel free to create a PR

所属分类

源码仓库

使用此插件的项目