Last active
February 15, 2019 12:02
-
-
Save magazmj/ada31013a9bffb805ea7d9c5f1b61820 to your computer and use it in GitHub Desktop.
GlowingOverscrollIndicator causes the blur effect of the BackdropFilter to be out of the range of the child widget
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
import 'dart:ui' as ui; | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: ScrollConfiguration( | |
behavior: AlwaysGlowingOverscrolBehavior(), | |
child: Scaffold(body: Container(color: Colors.white, child: Demo())), | |
), | |
); | |
} | |
} | |
class Demo extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Stack( | |
fit: StackFit.expand, | |
children: <Widget>[ | |
Text(List.filled(10000, '0').join().toString(), | |
style: TextStyle(color: Colors.black)), | |
Positioned( | |
top: 100.0, | |
bottom: 100.0, | |
left: 0.0, | |
right: 0.0, | |
child: BackdropFilter( | |
filter: ui.ImageFilter.blur( | |
sigmaX: 5.0, | |
sigmaY: 5.0, | |
), | |
child: Container( | |
color: Colors.black.withOpacity(0.5), | |
child: SingleChildScrollView( | |
child: Column( | |
children: <Widget>[ | |
Text( | |
'Top', | |
style: TextStyle(fontSize: 32.0, color: Colors.white), | |
), | |
Container( | |
height: 1000.0, | |
alignment: Alignment.center, | |
child: Text( | |
'Center', | |
style: TextStyle(fontSize: 32.0, color: Colors.white), | |
), | |
), | |
Text( | |
'Bottom', | |
style: TextStyle(fontSize: 32.0, color: Colors.white), | |
), | |
], | |
), | |
), | |
), | |
), | |
), | |
], | |
); | |
} | |
} | |
class AlwaysGlowingOverscrolBehavior extends ScrollBehavior { | |
@override | |
Widget buildViewportChrome( | |
BuildContext context, Widget child, AxisDirection axisDirection) { | |
return GlowingOverscrollIndicator( | |
child: child, | |
axisDirection: axisDirection, | |
color: Theme.of(context).accentColor, | |
); | |
} | |
@override | |
ScrollPhysics getScrollPhysics(BuildContext context) { | |
return const ClampingScrollPhysics(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment