프로그래밍/Flutter
Flutter 안드로이드에서 scrollview 반짝임(glow) 제거
sidongmen
2020. 11. 4. 00:40
플러터로 작성한 어플리케이션을 안드로이드 디바이스에서 실행하면 위처럼 스크롤 기능이 있는 위젯에서 터치에 의해 당겨지는 느낌의 effect를 볼 수 있다.
예전부터 너무 지우고 싶었던 효과라 stackoverflow에서 찾다가 발견해서 기록해둔다.
glow effect를 제거하는 Behavior을 생성한다. (ScrollBehavior 상속)
api.flutter.dev/flutter/widgets/ScrollBehavior-class.html
ScrollBehavior class - widgets library - Dart API
Describes how Scrollable widgets should behave. Used by ScrollConfiguration to configure the Scrollable widgets in a subtree. Annotations Constructors ScrollBehavior() Creates a description of how Scrollable widgets should behave. const Properties hashCode
api.flutter.dev
class MyBehavior extends ScrollBehavior {
@override
Widget buildViewportChrome(
BuildContext context, Widget child, AxisDirection axisDirection) {
return child;
}
}
앱 전체에 적용할 경우 최상단 MaterialApp에 아래와 같이 적용시킨다.
MaterialApp(
builder: (context, child) {
return ScrollConfiguration(
behavior: MyBehavior(),
child: child,
);
},
home: new MyHomePage(),
);
특정 ListView의 적용할 경우,
ScrollConfiguration(
behavior: MyBehavior(),
child: ListView(
...
),
)