Ink class

A convenience widget for drawing images and other decorations on Material widgets, so that InkWell and InkResponse splashes will render over them.

Ink splashes and highlights, as rendered by InkWell and InkResponse, draw on the actual underlying Material, under whatever widgets are drawn over the material (such as Text and Icons). If an opaque image is drawn over the Material (maybe using a Container or DecoratedBox), these ink effects will not be visible, as they will be entirely obscured by the opaque graphics drawn above the Material.

This widget draws the given Decoration directly on the Material, in the same way that InkWell and InkResponse draw there. This allows the splashes to be drawn above the otherwise opaque graphics.

An alternative solution is to use a MaterialType.transparency material above the opaque graphics, so that the ink responses from InkWells and InkResponses will be drawn on the transparent material on top of the opaque graphics, rather than under the opaque graphics on the underlying Material.

Limitations

This widget is subject to the same limitations as other ink effects, as described in the documentation for Material. Most notably, the position of an Ink widget must not change during the lifetime of the Material object unless a LayoutChangedNotification is dispatched each frame that the position changes. This is done automatically for ListView and other scrolling widgets, but is not done for animated transitions such as SlideTransition.

Additionally, if multiple Ink widgets paint on the same Material in the same location, their relative order is not guaranteed. The decorations will be painted in the order that they were added to the material, which generally speaking will match the order they are given in the widget tree, but this order may appear to be somewhat random in more dynamic situations.

Sample code

This example shows how a Material widget can have a yellow rectangle drawn on it using Ink, while still having ink effects over the yellow rectangle:

new Material(
  color: Colors.teal[900],
  child: new Center(
    child: new Ink(
      color: Colors.yellow,
      width: 200.0,
      height: 100.0,
      child: new InkWell(
        onTap: () { /* ... */ },
        child: new Center(
          child: new Text('YELLOW'),
        )
      ),
    ),
  ),
)

The following example shows how an image can be printed on a Material widget with an InkWell above it:

new Material(
  color: Colors.grey[800],
  child: new Center(
    child: new Ink.image(
      image: new AssetImage('cat.jpeg'),
      fit: BoxFit.cover,
      width: 300.0,
      height: 200.0,
      child: new InkWell(
        onTap: () { /* ... */ },
        child: new Align(
          alignment: Alignment.topLeft,
          child: new Padding(
            padding: const EdgeInsets.all(10.0),
            child: new Text('KITTEN', style: new TextStyle(fontWeight: FontWeight.w900, color: Colors.white)),
          ),
        )
      ),
    ),
  ),
)

See also:

Inheritance

Constructors

Ink({Key key, EdgeInsetsGeometry padding, Color color, Decoration decoration, double width, double height, Widget child })
Paints a decoration (which can be a simple color) on a Material. [...]
Ink.image({Key key, EdgeInsetsGeometry padding, @required ImageProvider image, ColorFilter colorFilter, BoxFit fit, AlignmentGeometry alignment: Alignment.center, Rect centerSlice, ImageRepeat repeat: ImageRepeat.noRepeat, bool matchTextDirection: false, double width, double height, Widget child })
Creates a widget that shows an image (obtained from an ImageProvider) on a Material. [...]

Properties

child Widget
The child contained by the container. [...]
final
decoration Decoration
The decoration to paint on the nearest ancestor Material widget. [...]
final
height double
A height to apply to the decoration and the child. The height includes any padding.
final
padding EdgeInsetsGeometry
Empty space to inscribe inside the decoration. The child, if any, is placed inside this padding. [...]
final
width double
A width to apply to the decoration and the child. The width includes any padding.
final
hashCode int
The hash code for this object. [...]
read-only, inherited
key Key
Controls how one widget replaces another widget in the tree. [...]
final, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

createState() → _InkState
Creates the mutable state for this widget at a given location in the tree. [...]
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree. [...]
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
@protected, inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toDiagnosticsNode({String name, DiagnosticsTreeStyle style }) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by toStringDeep. [...]
inherited
toString({DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a string representation of this object.
inherited
toStringDeep({String prefixLineOne: '', String prefixOtherLines, DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a string representation of this node and its descendants. [...]
inherited
toStringShallow({String joiner: ', ', DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a one-line detailed description of the object. [...]
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited