一、Flutter Card组件介绍:
Card是卡片组件块,内容可以由大多数类型的Widget构成,Card具有圆角和阴影,这让它看起来有立体感;但通常与ListTile一起使用,Card有一个child,但它可以是支持多个child的列,行,列表,网格或其他小部件,Card将其大小为0像素,可以使用SizeBox来限制Card的大小;Card容器不能滚动
二、Card构造属性
const Card({
Key key,
this.color, // 背影色
this.shadowColor,//阴影颜色
this.elevation, // 设置阴影长度
this.shape, // 阴影
this.borderOnForeground = true,
this.margin, // 外边距
this.clipBehavior,
this.child,
this.semanticContainer = true,
})
三、代码演示
import 'package:flutter/material.dart';
class CardPage extends StatefulWidget {
CardPage({Key key}) : super(key: key);
@override
_CardPageState createState() => _CardPageState();
}
class _CardPageState extends State {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("56zhiyi.com Card组件"),
),
body: Card(
child: Container(
child: ListTile(
title: Text("张三"),
subtitle: Text("总经理"),
),
),
),
);
}
}
四、效果图