首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >更改CustomScrollView的glov位置

更改CustomScrollView的glov位置
EN

Stack Overflow用户
提问于 2020-08-14 12:55:01
回答 1查看 137关注 0票数 0

我正在尝试改变滚动glov的位置,从顶部到底部的appBar内部的CustomScrollView。根据官方文档中的示例,我可以使用NotificationListener。但是当我尝试在我的代码中实现它时,notification.paintOffset没有定义。我应该怎么做,下面是我的代码:

代码语言:javascript
复制
class HomeView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _buildContent(context),
    );
  }

 Widget _buildContent(BuildContext context) {
  double leadingPaintOffset = MediaQuery.of(context).padding.top + AppBar().preferredSize.height;
  return NotificationListener<OverscrollIndicatorNotification>(
    onNotification: (notification) {
      if (notification.leading) {
        notification.paintOffset = leadingPaintOffset;
      }
      return false;
    },
    child: CustomScrollView(
      slivers: [
        SliverAppBar(title: Text('Custom PaintOffset')),
        SliverToBoxAdapter(
          child: Container(
            color: Colors.amberAccent,
            height: 100,
            child: Center(child: Text('Glow all day!')),
          ),
        ),
        SliverFillRemaining(child: FlutterLogo()),
      ],
    ),
  );

}
}

下面是一个例外:

代码语言:javascript
复制
The setter 'paintOffset' isn't defined for the class 'OverscrollIndicatorNotification'.
Try importing the library that defines 'paintOffset', correcting the name to the name of an existing setter, or defining a setter or field named 'paintOffset'.

所以,notification.paintOffset没有定义!求求你救命!这是官方文档的链接:https://api.flutter.dev/flutter/widgets/GlowingOverscrollIndicator-class.html

下面是Flutter doctor的输出:

代码语言:javascript
复制
√] Flutter (Channel stable, v1.12.13+hotfix.8, ...)
 
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[!] Android Studio (version 3.5)
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
[√] VS Code (version 1.47.3)
[!] Connected device
    ! No devices available

! Doctor found issues in 2 categories.

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-14 13:42:48

3个月前在this commit中引入了paintOffset

您将不会在以前的flutter版本(如您的v1.12.13)中找到它的定义。尝试将flutter升级到至少1.17.1,因为它是在2020年5月13日合并的

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63406776

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档