如何在Flutter中自定义TabBar的指示器和标签?

时间:2020-01-05 06:06:21

标签: flutter

我希望得到这样的期望:expected轻击时出现轻拍,但得到的是:what i get。我不知道如何获取单个标签的名称,但是基于要滚动的指示器,所有指示器(即已选择和未选定)都已选定。下面是我的代码:

                    DefaultTabController(
                    length: stages.length,
                    initialIndex: 0,
                    child: Column(
                    children: <Widget>[
                      Container(
                          height: 60.0,
                          width: width,
                          color: Colors.white,
                          child: TabBar(
                            isScrollable: true,
                            labelColor: Colors.teal,
                            indicatorColor: Colors.teal,
                            indicatorWeight: 2.0,
                            labelPadding:  EdgeInsets.only(right: 250.0, left: 40.0),
                            indicatorPadding: EdgeInsets.only(left: 40.0),
                            labelStyle: TextStyle(fontSize: 16.0),
                            tabs: List<Widget>.generate(stages.length,
                                    (int index) {
                                  String neStageName = stages[index];
                                  // print(dealList[0]);
                                  return new Tab(
                                      child: Row(
                                          children: <Widget>[
                                            CircleAvatar(
                                                backgroundColor: Colors.teal,
                                                child: Text( neStageName[0].toUpperCase())),
                                            Padding(
                                              padding: const EdgeInsets.all(8.0),
                                              child: Text(neStageName,
                                                  style: TextStyle(
                                                      color: Colors.black,
                                                      fontSize: 22.0)),
                                            )
                                          ]));
                                }),
                          )),
                      Container(
                          height: MediaQuery.of(context).size.height,
                          child: TabBarView(
                            children: List<Widget>.generate(stages.length,
                                    (int index) {
                                  stageName = stages[index];
                                  return FutureBuilder(
                                      future: _dealHelper.getDealPerStages(pipeId, stageName),
                                      builder: (context, snapshot) {
                                        return snapshot.data != null
                                            ? getLeadList(snapshot.data) : getLeadInListView();
                                      });
                                }),
                          ))
                    ],
                  ),
                )

0 个答案:

没有答案