1// Copyright 2014 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import 'package:flutter/material.dart';
6
7/// Flutter code sample for [Card].
8
9void main() => runApp(const CardExampleApp());
10
11class CardExampleApp extends StatelessWidget {
12 const CardExampleApp({super.key});
13
14 @override
15 Widget build(BuildContext context) {
16 return MaterialApp(
17 home: Scaffold(
18 appBar: AppBar(title: const Text('Card Sample')),
19 body: const CardExample(),
20 ),
21 );
22 }
23}
24
25class CardExample extends StatelessWidget {
26 const CardExample({super.key});
27
28 @override
29 Widget build(BuildContext context) {
30 return Center(
31 child: Card(
32 // clipBehavior is necessary because, without it, the InkWell's animation
33 // will extend beyond the rounded edges of the [Card] (see https://github.com/flutter/flutter/issues/109776)
34 // This comes with a small performance cost, and you should not set [clipBehavior]
35 // unless you need it.
36 clipBehavior: Clip.hardEdge,
37 child: InkWell(
38 splashColor: Colors.blue.withAlpha(30),
39 onTap: () {
40 debugPrint('Card tapped.');
41 },
42 child: const SizedBox(width: 300, height: 100, child: Text('A card that can be tapped')),
43 ),
44 ),
45 );
46 }
47}
48