Closed EsZhangHome closed 1 year ago
您好,我想自定义header ,这个header 是一个gif 图,用老版本的时候可以这样自定义,现在V3 版本的我想自定义,改如何自定义。下面是使用老版本库,自定义header 的代码,其中引用了一个 gif 图。 `///自定义顶部加载提示动画 class CustomRefreshHeader extends Header { /// Key final Key key;
final LinkHeaderNotifier linkNotifier = LinkHeaderNotifier();
CustomRefreshHeader({ this.key, bool enableHapticFeedback = true, bool enableInfiniteRefresh = false, }) : super( extent: 100.0, triggerDistance: 100.0, float: false, enableHapticFeedback: enableHapticFeedback, enableInfiniteRefresh: enableInfiniteRefresh, );
@override Widget contentBuilder( BuildContext context, RefreshMode refreshState, double pulledExtent, double refreshTriggerPullDistance, double refreshIndicatorExtent, AxisDirection axisDirection, bool float, Duration completeDuration, bool enableInfiniteRefresh, bool success, bool noMore) { // 不能为水平方向 assert( axisDirection == AxisDirection.down || axisDirection == AxisDirection.up, 'Widget cannot be horizontal'); linkNotifier.contentBuilder( context, refreshState, pulledExtent, refreshTriggerPullDistance, refreshIndicatorExtent, axisDirection, float, completeDuration, enableInfiniteRefresh, success, noMore); return Stack( children: [ Positioned( top: 0.0, bottom: 0.0, left: 0.0, right: 0.0, child: Container( alignment: Alignment.bottomCenter, color: Colors.transparent, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( Assets.imgLoadingTop, width: 100, height: 100, ), ], ), ), ), ], ); } }`
参考已有样式哈,照着写就可以,主要是高度和指示器的几个状态
您好,我想自定义header ,这个header 是一个gif 图,用老版本的时候可以这样自定义,现在V3 版本的我想自定义,改如何自定义。下面是使用老版本库,自定义header 的代码,其中引用了一个 gif 图。 `///自定义顶部加载提示动画 class CustomRefreshHeader extends Header { /// Key final Key key;
final LinkHeaderNotifier linkNotifier = LinkHeaderNotifier();
CustomRefreshHeader({ this.key, bool enableHapticFeedback = true, bool enableInfiniteRefresh = false, }) : super( extent: 100.0, triggerDistance: 100.0, float: false, enableHapticFeedback: enableHapticFeedback, enableInfiniteRefresh: enableInfiniteRefresh, );
@override Widget contentBuilder( BuildContext context, RefreshMode refreshState, double pulledExtent, double refreshTriggerPullDistance, double refreshIndicatorExtent, AxisDirection axisDirection, bool float, Duration completeDuration, bool enableInfiniteRefresh, bool success, bool noMore) { // 不能为水平方向 assert( axisDirection == AxisDirection.down || axisDirection == AxisDirection.up, 'Widget cannot be horizontal'); linkNotifier.contentBuilder( context, refreshState, pulledExtent, refreshTriggerPullDistance, refreshIndicatorExtent, axisDirection, float, completeDuration, enableInfiniteRefresh, success, noMore); return Stack( children:[
Positioned(
top: 0.0,
bottom: 0.0,
left: 0.0,
right: 0.0,
child: Container(
alignment: Alignment.bottomCenter,
color: Colors.transparent,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
Assets.imgLoadingTop,
width: 100,
height: 100,
),
],
),
),
),
],
);
}
}`