3

我在里面有“下一个”和“上一个”按钮flexibleSpace,如下所示,“下一个”和“上一个”按钮的文本在滚动时会隐藏,但前进和后退箭头不会隐藏。我希望它们在滚动时隐藏。

在此处输入图像描述

这是我的代码,

            SliverAppBar(
              backgroundColor: selectedColor ?? Colors.blue,
              expandedHeight: 112,
              snap: true,
              pinned: false,
              floating: true,
              forceElevated: true,
              actions: <Widget>[
                IconButton(
                    icon: Icon(Icons.event),
                    onPressed: () {
                      DateTime now = DateTime.now();
                      _selectDate(context, now);
                    })
              ],
              flexibleSpace: selectedTitle != null ? SafeArea(
                child: Column(
                  children: <Widget>[
                    Container(
                      height: kToolbarHeight,
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Text(
                            selectedTitle?.toUpperCase() ?? '',
                            style: Theme
                                .of(context)
                                .textTheme
                                .title
                                .copyWith(fontSize: 16, color: Colors.white),
                          ),
                          SizedBox(
                            height: 2,
                          ),
                          isWeekly
                              ? SizedBox(
                            height: 0,
                            width: 0,
                          )
                              : Text(
                            displayDate ?? '',
                            style: Theme
                                .of(context)
                                .textTheme
                                .caption
                                .copyWith(fontSize: 10, color: Colors.white),
                          ),
                          SizedBox(
                            height: 2,
                          ),
                          Text(
                            selectedParshaNodeModel?.parshaName ?? '',
                            style: Theme
                                .of(context)
                                .textTheme
                                .subtitle
                                .copyWith(fontSize: 14, color: Colors.white),
                          ),
                        ],
                      ),
                    ),
                    Expanded(
                      child: Container(
                        height: kToolbarHeight,
                        width: MediaQuery
                            .of(context)
                            .size
                            .width,
                        color: Colors.white,
                        child: Row(
                          children: <Widget>[
                            Expanded(
                                child:
                                FlatButton(
                                    onPressed: () {}
                                     ,
                                    child: Row(
                                      crossAxisAlignment:
                                      CrossAxisAlignment.center,
                                      mainAxisAlignment:
                                      MainAxisAlignment.spaceAround,
                                      children: <Widget>[
                                        Icon(Icons.arrow_back,
                                            color: Colors.grey),
                                        Text(
                                          'Prev',
                                          style: Theme
                                              .of(context)
                                              .textTheme
                                              .subhead
                                              .copyWith(color: Colors.grey),
                                        )
                                      ],
                                    ))),
                            Expanded(
                                child:
                                FlatButton(
                                    onPressed: (){},
                                    child: Row(
                                      mainAxisAlignment:
                                      MainAxisAlignment.spaceAround,
                                      crossAxisAlignment:
                                      CrossAxisAlignment.center,
                                      children: <Widget>[
                                        Text('Next',
                                            style: Theme
                                                .of(context)
                                                .textTheme
                                                .subhead
                                                .copyWith(color: Colors.grey)),
                                        Icon(
                                          Icons.arrow_forward,
                                          color: Colors.grey,
                                        ),
                                      ],
                                    )))
                          ],
                        ),
                      ),
                    )
                  ],
                ),
              ) : Container(),
            ),
4

1 回答 1

7

发生这种情况是因为箭头溢出了按钮的边界。添加clipBehavior: Clip.hardEdge应该可以解决您的问题:

child: FlatButton(
  clipBehavior: Clip.hardEdge,
  onPressed: () {},
  child: Row(
    ...Your Arrow and Text
  ),
),
于 2020-01-29T20:23:13.933 回答