flutter - 如何在 Flutter 中禁用 Tab Bar 项的突出显示和飞溅行为

标签 flutter dart

我只想在点击选项卡项时禁用或更改 highlightColorsplashColor 行为?

我的代码段,

SliverAppBar(
    backgroundColor: MyColors.darkGreen,
    elevation: 0.0,
    automaticallyImplyLeading: false,
    bottom: TabBar(
      isScrollable: true,
      unselectedLabelColor: Colors.grey,
      labelColor: Colors.white,
      onTap: (int itemIndex) {},
      indicatorSize: TabBarIndicatorSize.tab,
      indicator: BubbleTabIndicator(
        indicatorHeight: 25.0,
        indicatorColor: Colors.white38,
        tabBarIndicatorSize: TabBarIndicatorSize.tab,
      ),
      tabs: tabs,
      controller: _tabController,
    ),
    pinned: true,
    floating: false,
    title: _titleWidget,
),

指导我如何制作。

最佳答案

只需将您的 AppBar 放在带有透明 highlightColorsplashColor 的 Theme 中。
例如。

return Scaffold(
  appBar: PreferredSize(
    preferredSize: Size.fromHeight(70),
      child: Theme(
        data: ThemeData(
        highlightColor: Colors.transparent,
        splashColor: Colors.transparent,
      ),
      child: AppBar( ... )

关于flutter - 如何在 Flutter 中禁用 Tab Bar 项的突出显示和飞溅行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59004669/

相关文章:

flutter - 渲染streamBuilder之前的延迟

dart - 如何在dart编程语言中使用ceil?

firebase - 接收FCM通知点击事件

flutter - 在图像上添加小部件- flutter , Dart

dart - Dart 中输出或引用参数的等效代码

android - 在 flutter 中显示来自 Firestore 数据的卡片

flutter - 在 Flutter 中让 Container 填充 TableCell

android - setState() 回调参数在 flutter 中返回了一个 Future

java - 如何修复应用程序:lint error when building flutter app?

Flutter http 对象主体列表