I am developing an iOS application in flutter. I want a navigation bar which can be expandable. On expand there should be large title on left side and on collapse same title should be on top center. This thing is possible with CupertinoSliverNavigationBar
but I want to add a search field under the large title which should only appear when navigation bar should be expanded and on scroll up, first search bar should be scrolled up and then CupertinoSliverNavigationBar
. This is default behaviour in many iOS applications. Let me show an example
Default IOS Scrolling
You can notice in example when scroll up then first height of search bar gets decreases then navigation bar collapses and when scroll down then first navigation bar expands then height of search bar increases. This is what I achieved yet Achieved Result
This is my code
CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
controller: _scrollController,
slivers: <Widget> [
const CupertinoSliverNavigationBar(
largeTitle: Text('Products'),
stretch: true,
//backgroundColor: Colors.white,
border: Border(),
trailing: Icon(CupertinoIcons.add,color: CupertinoColors.systemBlue,size: 24,),
),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: CupertinoSearchTextField(
controller: _controller,
onSubmitted: (String value) {
},
),
),
),
SliverFillRemaining(
child: _controller.text.isNotEmpty?
paymentList(state.productDataSearch!,state):
paymentList(state.productData!,state),
),
],
),
I achieved this by using NotificationListener and change the height of textfield according to the position of scroll