答案 0 :(得分:3)
检查一下
class CustomIndicator extends StatelessWidget {
var radius = Radius.circular(10);
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
title: Text("Custom Indicator"),
bottom: TabBar(
tabs: <Widget>[
Tab(
text: "Hello",
),
Tab(
text: "Megan",
),
],
indicator: ShapeDecoration(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.only(topRight: radius, topLeft: radius)),
color: Colors.red
),
),
),
body: TabBarView(
children: <Widget>[
Container(
child: Center(
child: Text("Hello"),
),
),
Container(
child: Center(
child: Text("Hi"),
),
)
],
),
),
);
}
}
输出: