Flutter开发技巧ListView去除水波纹方法示例
Asscre 人气:0正文
ScrollConfiguration( behavior: NoScrollBehaviorWidget(), child: ListView( ...... ...... ), ),
- 调用ScrollConfiguration官方类,实现behavior
- NoScrollBehaviorWidget用于去除水波纹的自定义Widget
import 'package:flutter/material.dart'; /// 去除listview水印 /// ScrollConfiguration behavior class NoScrollBehaviorWidget extends ScrollBehavior { @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; } }
加载全部内容