Skip to content

Instantly share code, notes, and snippets.

@HansMuller
Last active June 10, 2021 06:36
Show Gist options
  • Save HansMuller/721b827a6c0300e2d57e86a65f599377 to your computer and use it in GitHub Desktop.
Save HansMuller/721b827a6c0300e2d57e86a65f599377 to your computer and use it in GitHub Desktop.
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(),
),
);
}
@AlexV525
Copy link

AlexV525 commented Jun 4, 2019

With 1.5.4-hotfix.2

class NoSplashFactory extends InteractiveInkFeatureFactory {
  const NoSplashFactory();

  @override
  InteractiveInkFeature create({
    @required MaterialInkController controller,
    @required RenderBox referenceBox,
    @required Offset position,
    @required Color color,
    @required TextDirection textDirection,
    bool containedInkWell = false,
    RectCallback rectCallback,
    BorderRadius borderRadius,
    ShapeBorder customBorder,
    double radius,
    VoidCallback onRemoved,
  }) {
    return 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) {
    controller.addInkFeature(this);
  }
  @override
  void paintFeature(Canvas canvas, Matrix4 transform) {}
}

@pishguy
Copy link

pishguy commented Jul 29, 2019

+1

@worldofsites
Copy link

For 2.20:

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,
    required TextDirection textDirection,
    bool containedInkWell = false,
    RectCallback? rectCallback,
    BorderRadius? borderRadius,
    ShapeBorder? customBorder,
    double? radius,
    VoidCallback? onRemoved,
  }) {
    return InkSplash(
      controller: controller,
      referenceBox: referenceBox,
      position: position,
      color: color,
      containedInkWell: containedInkWell,
      rectCallback: rectCallback,
      borderRadius: borderRadius,
      customBorder: customBorder,
      radius: radius,
      onRemoved: onRemoved,
      textDirection: textDirection,
    );
  }
}

class InkSplash extends InteractiveInkFeature {
  InkSplash({
    required MaterialInkController controller,
    required RenderBox referenceBox,
    required TextDirection textDirection,
    Offset? position,
    required Color color,
    bool containedInkWell = false,
    RectCallback? rectCallback,
    BorderRadius? borderRadius,
    ShapeBorder? customBorder,
    double? radius,
    VoidCallback? onRemoved,
  }) : super(
            controller: controller,
            referenceBox: referenceBox,
            color: color,
            onRemoved: onRemoved) {
    controller.addInkFeature(this);
  }

  @override
  void paintFeature(Canvas canvas, Matrix4 transform) {}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment