gpt4 book ai didi

flutter - 有没有办法使标签栏指示器在角落向下弯曲?

转载 作者:行者123 更新时间:2023-12-05 07:02:23 27 4
gpt4 key购买 nike

我在脚手架中的容器上放置了一个边界半径。我现在想要的是 TabBar 指示器与容器一起向下弯曲,而不是一条直线,这会导致指示器 float 在背景之上。该图像将显示我的意思。

我试过使用 TabBar 的指示器属性,但没有成功。

Picture of the app as example

Picture of result that I'm looking for (Photoshop)

包装器.dart

 Widget build(BuildContext context) => StoreConnector<AppState, Store<AppState>>(
converter: (Store<AppState> store) => store,
builder: (BuildContext context, Store<AppState> store) => Container(
decoration: widget.decoration,
child: Scaffold(
drawer: widget.drawer ? _menuDrawer(context, store) : null,
backgroundColor: Colors.transparent,
appBar: PreferredSize(
preferredSize: Size.fromHeight(widget.tabBar != null ? 110.0 : 60.0),
child: Container(
alignment: Alignment.center,
child: AppBar(
actions: widget.actions,
backgroundColor: Colors.transparent,
iconTheme: IconThemeData(color: Colors.white),
title: widget.teamIsPremium != null
? Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(widget.teamIsPremium ? MdiIcons.star : MdiIcons.starOff),
Container(
width: 5,
),
Text(widget.title),
],
)
: Text(widget.title),
centerTitle: true,
elevation: 0,
bottom: widget.tabBar,
))),
bottomNavigationBar: widget.selectedMenuItem == WrapperMenuItem.NONE
? null
: Theme(
data: Theme.of(context).copyWith(textTheme: Theme.of(context).textTheme),
child: BottomNavigationBar(
selectedItemColor: Color(0xff2e2e2e),
unselectedItemColor: Color(0xff757575),
currentIndex: _getIdFromEnum(widget.selectedMenuItem),
onTap: (i) => {
if (i != _getIdFromEnum(widget.selectedMenuItem))
{widget.selectedMenuItem = _getWrapperMenuItemFromId(i), _moveToPage(context, i)}
},
showSelectedLabels: true,
items: [
BottomNavigationBarItem(icon: Icon(MdiIcons.home), title: Text('Start')),
BottomNavigationBarItem(icon: Icon(MdiIcons.trafficCone), title: Text('Trainingen')),
BottomNavigationBarItem(icon: Icon(MdiIcons.trophy), title: Text('Wedstrijden')),
BottomNavigationBarItem(icon: Icon(MdiIcons.accountGroup), title: Text('Spelers'))
]),
),
body: Container(
margin: widget.small
? EdgeInsets.only(left: 5, right: 5, top: 5)
: widget.tabBar != null ? EdgeInsets.only(top: 0) : EdgeInsets.only(top: 0),
decoration: BoxDecoration(
color: widget.transparent ? Colors.transparent : Color.fromRGBO(240, 240, 240, 1),
borderRadius: BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15))),
constraints: BoxConstraints.expand(),
alignment: Alignment(-1, -1),
child: ClipRRect(
child: widget.child,
borderRadius: BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15)),
),
),
floatingActionButton: widget.floatingActionButton,
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
)));

比赛.飞镖

    return DefaultTabController(
length: 2,
child: Wrapper(
title: 'Wedstrijden',
drawer: true,
selectedMenuItem: WrapperMenuItem.MATCH,
tabBar: TabBar(
tabs: [
Tab(text: 'Overzicht'),
Tab(text: 'Statistieken'),
],
),
child: TabBarView(
children: [
MatchOverviewTab(),
MatchStatsTab(),
],
),
),
);

最佳答案

这是你可以尝试的方法,记住一切都是 flutter 中的小部件,所以首先,在你的脚手架中创建 Stack 放置你的 TabBar() 和 < strong>Container() 使用 Positioned 或任何其他使它们重叠到所需的程度然后你应该添加你的 Custom Indicator (在您的情况下,这将是一个带有圆边的容器)到 TabBar()


为了更清楚起见,这里有一张图片。 enter image description here

当然,有几种可能的方法,但这是我能想到的,您也会看到相同的指示器动画。很想知道它是否有效。

关于flutter - 有没有办法使标签栏指示器在角落向下弯曲?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63561744/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com