Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

包裹在折叠控件中,刷新后会自动折叠 #133

Closed
HeVTion opened this issue Jul 18, 2019 · 4 comments
Closed

包裹在折叠控件中,刷新后会自动折叠 #133

HeVTion opened this issue Jul 18, 2019 · 4 comments

Comments

@HeVTion
Copy link

HeVTion commented Jul 18, 2019

Widget build(BuildContext context) {
return Scaffold(
backgroundColor: yello,
body: SafeArea(
child: NestedScrollView( //scrollview
controller: _scrollController,
headerSliverBuilder: (context, bool) { //头部折叠
return [
SliverAppBar(
expandedHeight: ScreenUtil.getInstance().setHeight(100),
pinned: false,
elevation: 0,
primary: false,
brightness: Brightness.light,
flexibleSpace: mySearch(),
// bottom: myTabBar(),
),
SliverPersistentHeader(
delegate: SliverTabBarDelegate(myTabBar(), color: Colors.white),
pinned: true,
floating: false,
),
];
},

刷新后,自动滑到顶部,折叠SliverAppBar

@peng8350
Copy link
Owner

代码详细点,smartrefresher还有child,还有nested里的_scrollController做了什么操作

@HeVTion
Copy link
Author

HeVTion commented Jul 18, 2019

NestedScrollView 放了 headerSliverBuilder

SafeArea(
child: NestedScrollView(
controller: _scrollController,
headerSliverBuilder: (context, bool) {
return [
SliverAppBar(
expandedHeight: ScreenUtil.getInstance().setHeight(100),
pinned: false,
elevation: 0,
primary: false,
brightness: Brightness.light,
flexibleSpace: mySearch(),
// bottom: myTabBar(), ///tabbar 会悬浮于顶部
),
SliverPersistentHeader(
delegate: SliverTabBarDelegate(myTabBar(), color: Colors.white),
pinned: true,
floating: false,
),
];
},
body: Container(
color: Colors.white,
padding: EdgeInsets.all(0),
child: TabBarView(controller: _tabController, children: [
myPage(),
myPage(),
myPage(),
myPage(),
myPage(),
myPage(),
myPage(),
myPage(),
myPage(),
myPage(),
myPage(),
myPage(),
]),
),
))

///smartrefresher 中放了ListView.builder ,
myPage() {
return SmartRefresher(
child: ListView.builder(
padding: EdgeInsets.all(0),
itemBuilder: (BuildContext context, int i) {
return Container(
color: Colors.white,
padding: EdgeInsets.only(left: 15, right: 15, top: 15),
child: FractionallySizedBox(
child: i % 2 == 1 ? listA(mData[i]) : listB(mData[i]),
));
},
itemCount: mData.length,
),
controller: _refreshController,
);
}

///_scrollController 什么也没做。

因为,也就是说nested上有个head可以被折叠,滑动到顶部后显示, 使用smart之后没有滑动到顶部,直接折叠了head

@peng8350
Copy link
Owner

Untitled
我没看出来哪里有问题啊,你可以对比一下这里的例子,看看哪里有问题

@JamesGZM
Copy link

Untitled
我没看出来哪里有问题啊,你可以对比一下这里的例子,看看哪里有问题

加了 scrollController 就会有问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants