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

設定CustomScrollView屬性center後無法觸發onRefresh和無法顯示header #469

Closed
WingCH opened this issue Apr 20, 2021 · 1 comment

Comments

@WingCH
Copy link

WingCH commented Apr 20, 2021

我的場境:
假設現在是在第二分頁,下拉加載上一頁(第一頁),上拉加載下一頁(第三頁),
我找到教學是使用CustomScrollView -> center key 來做類似的效果

  1. https://dartpad.dartlang.org/c3b9b03925cdaaf88c1b8fe78a3b96b0
  2. https://dartpad.dartlang.org/38a9320bb8edd30af3c8543c24df8a21

flutter/flutter#21541

根據上面的教學我嘗試使用flutter_easyrefresh 實現,
在example (https://github.com/xuelongqy/flutter_easyrefresh/blob/v2/example/lib/page/sample/swiper.dart), 在CustomScrollViewSliverList 加入 center key 會無法觸發onRefresh和無法顯示header

class SwiperPageState extends State<SwiperPage> {
  // 条目总数
  int _count = 20;

  @override
  Widget build(BuildContext context) {
    const Key centerKey = ValueKey('second-sliver-list'); // <-----

    return Scaffold(
      body: EasyRefresh.builder(
        builder: (context, physics, header, footer) {
          return CustomScrollView(
            center: centerKey, // <-----
            physics: physics,
            slivers: <Widget>[
              SliverAppBar(
                expandedHeight: 100.0,
                pinned: true,
                backgroundColor: Colors.white,
                flexibleSpace: FlexibleSpaceBar(
                  centerTitle: false,
                  title: Text('Swiper'),
                ),
              ),
              header,
              SliverList(
                key: centerKey, // <-----
                delegate: SliverChildListDelegate([
                  Container(
                    height: 210.0,
...

正常情況

Screenrecorder-2021-04-20-23-07-35-203.mp4

加入centerKey 後

Screenrecorder-2021-04-20-23-08-06-917.mp4

求指教!

@xuelongqy
Copy link
Owner

v3已发布,也许问题得到解决。如果问题依然存在,请重新打开

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

2 participants