【问题标题】:Is there BottomNavigationBar for CustomScrollView?CustomScrollView 是否有 BottomNavigationBar?
【发布时间】:2018-07-06 17:05:00
【问题描述】:

我可以将 CustomScrollView 的 BottomNavigationBar 例如 SliverAppBar 作为 CustomScrollView 中的 Appbar 吗?

当我向下滚动以隐藏它然后向上滚动以显示它时。

【问题讨论】:

    标签: flutter


    【解决方案1】:

    我在应用程序中以这种方式使用这些小部件,希望对您有所帮助!

                  return SafeArea(
                    child: Scaffold(
                      body: CustomScrollView(slivers: <Widget>[
                        SliverAppBar(
                          title: Form(
                            child: TextFormField(
                              maxLines: null,
                              autovalidate: true,
                              textInputAction: TextInputAction.done,
                              onFieldSubmitted: (value) {
                                _searchProduct(value);
                                _inputCodeController.text = "";
                              },
                              style: TextStyle(color: Colors.white, fontSize: 22.0),
                              keyboardType: keyboardTypeFix,
                              controller: _inputCodeController,
                              autofocus: _autoFocusInputCode,
                              decoration: InputDecoration(
                                  border: InputBorder.none,
                                  hintStyle: TextStyle(
                                      color: Colors.white, fontSize: 20.0),
                                  hintText: 'Barcode'),
                            ),
                          ),
                          floating: true,
                          snap: true,
                          actions: <Widget>[
                            IconButton(
                              icon: Icon(Icons.add),
                              onPressed: () {
                                _addProductVarious(context);
                              },
                            ),
                            IconButton(
                                icon: Icon(Icons.crop_free), onPressed: _scanQR),
                          ],
                        ),
                        new SliverPadding(
                          padding: EdgeInsets.symmetric(vertical: 8.0),
                          sliver: SliverList(
                              delegate: new SliverChildListDelegate(
                                  buildItemsViews(_cartItemList))),
                        )
                      ]),
                      floatingActionButton: FloatingActionButton(
                        elevation: 4.0,
                        child: const Icon(Icons.attach_money),
                        onPressed: _closeCart,
                      ),
                      floatingActionButtonLocation:
                          FloatingActionButtonLocation.endDocked,
                      bottomNavigationBar: BottomAppBar(
                        child: new Row(
                          mainAxisSize: MainAxisSize.max,
                          mainAxisAlignment: MainAxisAlignment.start,
                          children: <Widget>[
                            Padding(
                              padding: EdgeInsets.symmetric(
                                  vertical: 12.0, horizontal: 12.0),
                              child: Text(
                                _cartTotalText,
                                style: TextStyle(fontSize: 18.0),
                              ),
                            )
                          ],
                        ),
                      ),
                    ));
    

    【讨论】:

    • 对于“当我向下滚动以隐藏它然后向上滚动以显示它时。”在 true 中使用浮动和对齐
    猜你喜欢
    • 2019-07-25
    • 1970-01-01
    • 1970-01-01
    • 2020-10-11
    • 1970-01-01
    • 2020-11-27
    • 2019-04-21
    • 1970-01-01
    • 2019-03-31
    相关资源
    最近更新 更多