美文网首页Flutter学习
Flutter ---- 滚动控件去除默认阴影

Flutter ---- 滚动控件去除默认阴影

作者: 三也视界 | 来源:发表于2021-08-09 16:26 被阅读0次

    方法1:
    The following ScrollBehavior will remove the glow effect entirely :

    class MyBehavior extends ScrollBehavior {
      @override
      Widget buildViewportChrome(
          BuildContext context, Widget child, AxisDirection axisDirection) {
        return child;
      }
    }
    

    To remove the glow on the whole application, you can add it right under MaterialApp :

    MaterialApp(
      builder: (context, child) {
        return ScrollConfiguration(
          behavior: MyBehavior(),
          child: child,
        );
      },
      home: new MyHomePage(),
    );
    

    To remove it on a specific ListView, instead wrap only the desired ListView :

    ScrollConfiguration(
      behavior: MyBehavior(),
      child: ListView(
        ...
      ),
    )
    

    方法2:推荐

    NotificationListener<OverscrollIndicatorNotification>(
        onNotification: (OverscrollIndicatorNotification? overscroll) {
          overscroll!.disallowGlow();
          return true;
        },
      child: child,
    ),
    

    相关文章

      网友评论

        本文标题:Flutter ---- 滚动控件去除默认阴影

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