搜索分类、插件与代码仓

animated_segmented_tab_control 封面
插件详情v2.2.0

animated_segmented_tab_control

一个可自定义的分段控件,可用于标签视图中。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
3840
喜欢数
100
Pub 分数
160

安装插件

flutter pub add animated_segmented_tab_control

插件介绍

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

一个可自定义的动画分段控件,专为与 Flutter 应用中的 TabView 无缝配合而设计。它提供平滑的段间过渡效果,支持多种样式选项,并通过动态视觉反馈增强用户交互体验。适用于需要直观标签导航且具有现代美学的应用程序。该包可在所有主要平台(包括 Android、iOS、Web、macOS、Windows 和 Linux)上兼容使用。

适合场景

  • 交互式标签导航
  • 动态UI过渡
  • 可自定义的标签界面
  • 跨平台标签控件
  • 仪表板中的用户体验增强
  • 表单部分切换

主要特点

  • 流畅的动画过渡
  • 高度可定制的外观
  • 内置的 TabView 支持
  • 跨平台响应式设计
  • 与现有 Flutter 项目的轻松集成
  • 支持横向和纵向布局

适合对象

  • 开发跨平台应用的开发者
  • 寻求现代 UI 组件的设计师
  • 包含多个内容区域的应用程序
  • 需要交互式标签体验的项目
  • 优先考虑跨设备的一致用户体验

使用建议

  • 可能需要为复杂主题添加额外的样式
  • 大量分段带来的性能影响
  • 有限的内置辅助功能
  • 依赖外部 TabView 实现
  • 未针对极高频率的更新进行优化

原始 README

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

A customizable segment tab control. Can be used with or without TabView.

Made in lanars.com.

pub package

Features

The package provides an advanced segmented control widget based on the TabController.

Usage

The package contains a SegmentedTabControl widget that requires a SegmentTab list.

SegmentedTabControl(
  tabs: [
    SegmentTab(
      label: 'Home',
    ),
  ],
)

SegmentedTabControl also requires a TabController. You can provide it with a DefaultTabController or instantiate a TabController instead.

DefaultTabController(
  length: 2,
  child: SegmentedTabControl(
    tabs: [
      SegmentTab(
        label: 'Home',
      ),
      SegmentTab(
        label: 'Account',
      ),
    ],
  ),
)

You can style the whole widget, an individual tab, or both. A value on the currently selected SegmentTab overrides the corresponding value on SegmentedTabControl.

SegmentedTabControl(
  barDecoration: BoxDecoration(
    color: Colors.grey.shade300,
    borderRadius: BorderRadius.circular(10),
  ),
  indicatorDecoration: BoxDecoration(
    color: Colors.orange.shade200,
    borderRadius: BorderRadius.circular(10),
  ),
  tabTextColor: Colors.black45,
  selectedTabTextColor: Colors.white,
  tabs: [
    SegmentTab(
      label: 'ACCOUNT',
      color: Colors.red.shade200,
    ),
    SegmentTab(
      label: 'HOME',
      backgroundColor: Colors.blue.shade100,
      selectedTextColor: Colors.black45,
      textColor: Colors.black26,
    ),
    const SegmentTab(label: 'NEW'),
  ],
)

Note that the text colors are read from the selected tab and applied to the whole bar, so textColor and selectedTextColor set the bar's label colors while that tab is selected rather than coloring only that one tab.

Change tracking logic is identical to TabBar logic.

DefaultTabController.of(context).index

or

_controller.index

Сustom tab content

Use SegmentTab.labelBuilder to show any widget like an icon.

The selected-tab highlight is produced by painting the tab row twice and clipping the upper copy to the indicator, so the builder is called once per layer and receives the color of the layer it is painting. Plain Icon and Text children inherit that color. Use color for anything that does not inherit it, such as a border or an SVG:

SegmentTab(
  label: 'NEW',
  labelBuilder: (context, color) => Container(
    padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
    decoration: BoxDecoration(
      border: Border.all(color: color),
      borderRadius: BorderRadius.circular(20),
    ),
    child: Text('NEW'),
  ),
)

Interactive children are not supported.

Additional information

If you have any ideas or are running into a bug, please submit an issue on github page: https://github.com/LanarsInc/animated-segmented-tab-control/issues

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。