美文网首页
Flutter 滚动类型组件隐藏水波纹

Flutter 滚动类型组件隐藏水波纹

作者: 梁典典 | 来源:发表于2021-07-17 10:50 被阅读0次
    // Flutter imports:
    import 'package:flutter/material.dart';
    
    /// 隐藏水波纹配置
    class NoShadowScrollBehavior extends ScrollBehavior {
      @override
      Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) {
        switch (getPlatform(context)) {
          case TargetPlatform.iOS:
          case TargetPlatform.macOS:
            return child;
          case TargetPlatform.android:
            return GlowingOverscrollIndicator(
              showLeading: false,
              showTrailing: false,
              axisDirection: axisDirection,
              color: Theme.of(context).accentColor,
              child: child,
            );
          case TargetPlatform.fuchsia:
          case TargetPlatform.linux:
          case TargetPlatform.windows:
            return GlowingOverscrollIndicator(
              //不显示头部水波纹
              showLeading: false,
              //不显示尾部水波纹
              showTrailing: false,
              axisDirection: axisDirection,
              color: Theme.of(context).accentColor,
              child: child,
            );
        }
      }
    }
    
    

    使用

                  ScrollConfiguration(
                      behavior: NoShadowScrollBehavior(),
                      child: SingleChildScrollView(
                        physics: BouncingScrollPhysics(),
                 
                      ),
                    )
    

    相关文章

      网友评论

          本文标题:Flutter 滚动类型组件隐藏水波纹

          本文链接:https://www.haomeiwen.com/subject/zpfwpltx.html