Last active
June 10, 2021 06:36
-
-
Save HansMuller/721b827a6c0300e2d57e86a65f599377 to your computer and use it in GitHub Desktop.
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 'package:flutter/material.dart'; | |
class NoSplashFactory extends InteractiveInkFeatureFactory { | |
const NoSplashFactory(); | |
@override | |
InteractiveInkFeature create({ | |
@required MaterialInkController controller, | |
@required RenderBox referenceBox, | |
@required Offset position, | |
@required Color color, | |
bool containedInkWell: false, | |
RectCallback rectCallback, | |
BorderRadius borderRadius, | |
double radius, | |
VoidCallback onRemoved, | |
}) { | |
return new NoSplash( | |
controller: controller, | |
referenceBox: referenceBox, | |
color: color, | |
onRemoved: onRemoved, | |
); | |
} | |
} | |
class NoSplash extends InteractiveInkFeature { | |
NoSplash({ | |
@required MaterialInkController controller, | |
@required RenderBox referenceBox, | |
Color color, | |
VoidCallback onRemoved, | |
}) : assert(controller != null), | |
assert(referenceBox != null), | |
super(controller: controller, referenceBox: referenceBox, onRemoved: onRemoved) { | |
// Added per https://github.com/flutter/flutter/issues/20874 | |
controller.addInkFeature(this); | |
} | |
@override | |
void paintFeature(Canvas canvas, Matrix4 transform) { } | |
} | |
class TextFieldsPage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
appBar: new AppBar(title: const Text('TextFields')), | |
body: new Container( | |
padding: const EdgeInsets.all(48.0), | |
alignment: Alignment.topLeft, | |
child: new Column( | |
crossAxisAlignment: CrossAxisAlignment.stretch, | |
children: <Widget>[ | |
new Theme( | |
data: Theme.of(context).copyWith( | |
splashFactory: const NoSplashFactory(), | |
), | |
child: new TextField(), | |
), | |
const SizedBox(height: 24.0), | |
new TextField(), | |
], | |
), | |
), | |
); | |
} | |
} | |
class HomePage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
appBar: new AppBar(title: const Text('NoSplashFactory')), | |
body: new Center( | |
child: new RaisedButton( | |
child: const Text('Push TextFields Page'), | |
onPressed: () { | |
Navigator.of(context).push( | |
new MaterialPageRoute(builder: (BuildContext context) => new TextFieldsPage()), | |
); | |
}, | |
), | |
), | |
); | |
} | |
} | |
void main() { | |
runApp( | |
new MaterialApp( | |
home: new HomePage(), | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For 2.20: