Flutter开发技巧ListView去除水波纹方法分享
Flutter开发技巧ListView去除水波纹详细方法如下:
ScrollConfiguration(
behavior: NoScrollBehaviorWidget(),
child: ListView(
......
......
),
),
调用ScrollConfiguration官方类,实现behavior NoScrollBehaviorWidget用于去除水波纹的自定义Widget
import 'package:flutter/material.dart';
/// 去除listview水印
/// ScrollConfiguration behavior
class NoScrollBehaviorWidget extends ScrollBehavior {
[@override](/user/override)
Widget buildViewportChrome(BuildContext context, Widget child,
AxisDirection axisDirection) {
switch (getPlatform(context)) {
case TargetPlatform.iOS:
return child;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
return GlowingOverscrollIndicator(
axisDirection: axisDirection,
color: Theme
.of(context)
.accentColor,
child: child,
showTrailing: false,
showLeading: false,);
case TargetPlatform.linux:
break;
case TargetPlatform.macOS:
break;
case TargetPlatform.windows:
break;
}
return child;
}
}