波动边界半径TabBar指示器

时间:2020-04-02 17:26:50

标签: flutter flutter-layout

pollOptionId中,如何绘制下图所示的边框半径标签指示符?

enter image description here

下面的代码只能绘制我在poll中找到的圆圈指示器。

subjectId

图书馆:

poll

1 个答案:

答案 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"),
              ),
            )
          ],
        ),
      ),
    );
  }
}

输出:

enter image description here