类型"固定滚动度量"不是"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);
}
}

最新更新