Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Jonas-Sander/6047eef6f5c8a1cc9e861601220f9f0d to your computer and use it in GitHub Desktop.
Save Jonas-Sander/6047eef6f5c8a1cc9e861601220f9f0d to your computer and use it in GitHub Desktop.
Flutter GlowingOverscrollColorChanger
/// Overrides the [GlowingOverscrollIndicator] color used by descendant widgets.
class GlowingOverscrollColorChanger extends StatelessWidget {
final Widget child;
final Color color;
const GlowingOverscrollColorChanger({Key key, this.child, this.color})
: super(key: key);
@override
Widget build(BuildContext context) {
return ScrollConfiguration(
behavior: SpecifiableOverscrollColorScrollBehavior(color),
child: child,
);
}
}
class SpecifiableOverscrollColorScrollBehavior extends ScrollBehavior {
final Color _overscrollColor;
const SpecifiableOverscrollColorScrollBehavior(this._overscrollColor);
@override
Widget buildViewportChrome(
BuildContext context, Widget child, AxisDirection axisDirection) {
switch (getPlatform(context)) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return child;
case TargetPlatform.windows:
case TargetPlatform.linux:
case TargetPlatform.android:
case TargetPlatform.fuchsia:
default:
return GlowingOverscrollIndicator(
child: child,
axisDirection: axisDirection,
color: _overscrollColor,
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment