Created
April 20, 2020 14:07
-
-
Save Jonas-Sander/6047eef6f5c8a1cc9e861601220f9f0d to your computer and use it in GitHub Desktop.
Flutter GlowingOverscrollColorChanger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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