如何解决“ FixedScrollMetrics”类型不是“ PageMetrics”类型的子类型
我在PageView中使用ListView。
在pubspec.yaml中:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
page_indicator: ^0.3.0
Wigdet中的代码:
GlobalKey _pageKey =新的GlobalKey();
PageIndicatorContainer(
key: _pageKey,length: 2,indicatorSpace: 5.0,shape:IndicatorShape.roundRectangleShape(
size: Size(50.0,12.0),),indicatorSelectorColor: white,indicatorColor: white,child: PageView(
controller: controller,children: <Widget>[
Container(
child:
childAppbar(),ListView(),],
解决方法
解决方法是在 FixedScrollMetrics
上使用此扩展:
extension on FixedScrollMetrics {
double get page {
return math.max(0.0,pixels.clamp(minScrollExtent,maxScrollExtent)) /
math.max(1.0,viewportDimension);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。