【问题标题】:Flutter TabBar custom indicatorFlutter TabBar 自定义指标
【发布时间】:2020-06-18 01:41:07
【问题描述】:

要了解我想要实现的目标,请查看屏幕截图:

但正如您所见,选项卡的阴影无法容纳在选项卡内。 那么如何为阴影腾出空间呢?

这是我构建标签的方法:

Tab buildTab(CategoryModel category) {
return Tab(child: ConstrainedBox(
  constraints: BoxConstraints(
    minWidth: 48,
  ),
  child: Container(
    //color: Colors.green,
    child: Text(category.name, textAlign: TextAlign.center,),
  ),
),);

}

这就是我构建 TabBar 的方式:

return TabBar(
  indicator: BoxDecoration(
      color: Colors.blue,
      borderRadius: const BorderRadius.all(
        const Radius.circular(999.0),
      ),
      boxShadow: const [BoxShadow(color: Colors.blueAccent, blurRadius: 6.0)]
  ),
  unselectedLabelColor: Colors.blue,
  labelColor: Colors.white,
  isScrollable: true,
  tabs: tabs,
);

【问题讨论】:

    标签: flutter tabs shadow tabbarcontroller


    【解决方案1】:

    标签栏代码有父级吗? 当我测试时,它运行良好。

    【讨论】:

    • 是的,它工作得很好,但是每个选项卡的阴影的顶部和底部没有显示,因为没有足够的空间。我想调整一下。
    • 尝试添加更多标签,以便标签栏滚动。此外,尝试给 blurRadius 一个更高的值,例如 32、48。
    猜你喜欢
    • 2020-12-31
    • 2020-11-28
    • 2019-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-28
    相关资源
    最近更新 更多