Flutter开发技巧ListView去除水波纹方法示例

正文ScrollConfiguration(behavior: NoScrollBehaviorWidget(),child: ListView(

正文

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;
  }
}

以上就是Flutter开发技巧ListView去除水波纹方法示例的详细内容,更多关于Flutter ListView去除水波纹的资料请关注好代码网其它相关文章!

您可能有感兴趣的文章
Flutter入门学习Dart语言变量及基本如何使用概念

Flutter 异步编程之单线程下异步模型图文示例详解

如何如何使用Flutter开发一款电影APP详解

Flutter进阶之如何实现动画效果(二)

Flutter定义tabbar底部导航路由跳转的方法