第一种方法,全局修改
配置 ThemeData(flutter 2.5.0)
ColorScheme colorScheme = ColorScheme.light(secondary: Color(0xffF05D5C)); ThemeData( colorScheme: colorScheme, );
第二种方法,单次修改
使用 ScrollConfiguration 和 GlowingOverscrollIndicator
@override Widget build(BuildContext context) { ... return ScrollConfiguration( behavior: MyBehavior(), child: listViewWidget ); }
MyBehavior如下
class MyBehavior extends ScrollBehavior { @override Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) { return GlowingOverscrollIndicator( child: child, axisDirection: axisDirection, color: 设置颜色, ); } @override ScrollPhysics getScrollPhysics(BuildContext context) { return ClampingScrollPhysics(); } @override TargetPlatform getPlatform(BuildContext context) { return Theme.of(context).platform; } }