FlatButton class

A material design "flat button".

A flat button is a text label displayed on a (zero elevation) Material widget that reacts to touches by filling with color.

Use flat buttons on toolbars, in dialogs, or inline with other content but offset from that content with padding so that the button's presence is obvious. Flat buttons intentionally do not have visible borders and must therefore rely on their position relative to other content for context. In dialogs and cards, they should be grouped together in one of the bottom corners. Avoid using flat buttons where they would blend in with other content, for example in the middle of lists.

Material design flat buttons have an all-caps label, some internal padding, and some defined dimensions. To have a part of your application be interactive, with ink splashes, without also committing to these stylistic choices, consider using InkWell instead.

If the onPressed callback is null, then the button will be disabled, will not react to touch, and will be colored as specified by the disabledColor property instead of the color property. If you are trying to change the button's color and it is not having any effect, check that you are passing a non-null onPressed handler.

Flat buttons will expand to fit the child widget, if necessary.

See also:

Inheritance

Constructors

FlatButton({Key key, @required VoidCallback onPressed, ButtonTextTheme textTheme, Color textColor, Color disabledTextColor, Color color, Color disabledColor, Color highlightColor, Color splashColor, Brightness colorBrightness, EdgeInsetsGeometry padding, ShapeBorder shape, @required Widget child })
Create a simple text button.
const
FlatButton.icon({Key key, @required VoidCallback onPressed, ButtonTextTheme textTheme, Color textColor, Color disabledTextColor, Color color, Color disabledColor, Color highlightColor, Color splashColor, Brightness colorBrightness, ShapeBorder shape, @required Widget icon, @required Widget label })
Create a text button from a pair of widgets that serve as the button's icon and label. [...]

Properties

child Widget
The widget below this widget in the tree. [...]
final
color Color
The button's fill color, displayed by its Material, while it is in its default (unpressed, enabled) state. [...]
final
colorBrightness Brightness
The theme brightness to use for this button. [...]
final
disabledColor Color
The fill color of the button when the button is disabled. [...]
final
disabledTextColor Color
The color to use for this button's text when the button is disabled. [...]
final
enabled bool
Whether the button is enabled or disabled. [...]
read-only
highlightColor Color
The highlight color of the button's InkWell. [...]
final
onPressed VoidCallback
Called when the button is tapped or otherwise activated. [...]
final
padding EdgeInsetsGeometry
The internal padding for the button's child. [...]
final
shape ShapeBorder
The shape of the button's Material. [...]
final
splashColor Color
The splash color of the button's InkWell. [...]
final
textColor Color
The color to use for this button's text. [...]
final
textTheme ButtonTextTheme
Defines the button's base colors, and the defaults for the button's minimum size, internal padding, and shape. [...]
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

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget. [...]
debugFillProperties(DiagnosticPropertiesBuilder description) → void
createElement() StatelessElement
Creates a StatelessElement 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 ==(other) bool
The equality operator. [...]
inherited