Card class
A card surface with optional pressable/hoverable/blur treatments.
Content comes either from child or from the CardHeader / CardBody / CardFooter slots (laid out in a 12px-gap column). CardVariant picks the surface treatment (transparent/default/ secondary/tertiary/outline); only default_ has a shadow by default, while outline adds the theme border. isPressable (or a non-null onPressed) wraps the card in touch handling; isBlurred swaps the solid container for a frosted-glass Blur. Customize the surface with color, border, shadows or padding.
Card(
header: const CardHeader(child: CardTitle(child: Text('Plan'))),
body: const CardBody(child: Text('Everything you need.')),
footer: CardFooter(child: Button.primary(onPressed: buy, child: const Text('Buy'))),
)
- Inheritance
Constructors
-
Card({Key? key, Widget? child, Widget? header, Widget? body, bool isPressable = false, bool isHoverable = false, bool isBlurred = false, VoidCallback? onPressed, VoidCallback? onLongPress, RadiusToken? radius, CardVariant variant = CardVariant.default_, Color? color, BorderSide? border, List<
BoxShadow> ? shadows, EdgeInsetsGeometry? padding, Clip clipBehavior = Clip.antiAlias, double? width, double? height}) -
Creates a card.
const
Properties
- body → Widget?
-
Middle slot (typically a CardBody).
final
- border → BorderSide?
-
Optional border side drawn around the card.
final
- child → Widget?
-
Direct content; when null, header+body+footer are used instead.
final
- clipBehavior → Clip
-
How the content is clipped at the card's edge.
final
- color → Color?
-
Explicit background color overriding the variant.
final
-
Bottom slot (typically a CardFooter).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- header → Widget?
-
Top slot (typically a CardHeader); ignored when child is set.
final
- height → double?
-
Height of the card. Null sizes the card to its content.
final
- isBlurred → bool
-
Renders as frosted glass (Blur) tinted with the resolved background.
final
- isHoverable → bool
-
Reserved for hover styling parity; hover feedback is handled by
consumers via
builder-style widgets.final - isPressable → bool
-
Enables touch/press feedback even without onPressed.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- onLongPress → VoidCallback?
-
Called when the card is long-pressed. Only used while the card is pressable.
final
- onPressed → VoidCallback?
-
Called when the card is tapped. Setting it makes the card pressable.
final
- padding → EdgeInsetsGeometry?
-
Outer padding for the whole content; defaults to none.
final
- radius → RadiusToken?
-
Corner radius token. Defaults to
SurfaceDefaults.radius, then RadiusToken.r2xl.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
shadows
→ List<
BoxShadow> ? -
Overrides the default small shadow (and SurfaceDefaults.shadows).
final
- variant → CardVariant
-
Background tier (only CardVariant.default_ has a default shadow).
final
- width → double?
-
Width of the card. Null sizes the card to its content.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
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.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent 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 DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → 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 ==(
Object other) → bool -
The equality operator.
inherited