我可以将CustomScrollView的BottomNavigationBar(例如SliverAppBar)制作为CustomScrollView中的Appbar吗?
当我向下滚动以隐藏它,然后向上滚动以显示它时。
答案 0 :(得分: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),
),
)
],
),
),
));