import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("卡片"), // 标题
leading: Icon(Icons.menu), // 左侧图标
actions: [Icon(Icons.settings)], // 右侧图标数组
elevation: 0.0,// 去掉阴影
centerTitle: true, // 标题居中
),
body:CardDemo()
);
}
}
class CardDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: [
Card(
margin: EdgeInsets.all(30),
color: Colors.purpleAccent[100],
shadowColor: Colors.yellow,
elevation: 20,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40),
side: BorderSide(
color: Colors.yellow,
width: 3
)
),
child: Column(
children: [
ListTile(
leading: Icon(
Icons.supervised_user_circle_rounded,
size: 50,
),
title: Text(
"张三",
style: TextStyle(
fontSize: 30
),
),
subtitle: Text(
"懂事长",
style: TextStyle(
fontSize: 20
),
),
),
ListTile(
title: Text(
"电话:13xxxxxx",
style: TextStyle(
fontSize: 20
),
),
),
ListTile(
title: Text(
"地址:00000000",
style: TextStyle(
fontSize: 20
),
),
),
],
),
),
Card(
child: Column(
children: [
ListTile(
leading: Icon(
Icons.supervised_user_circle_rounded,
size: 50,
),
title: Text(
"李四",
style: TextStyle(
fontSize: 30
),
),
subtitle: Text(
"总经理",
style: TextStyle(
fontSize: 20
),
),
),
ListTile(
title: Text(
"电话:13xxxxxx",
style: TextStyle(
fontSize: 20
),
),
),
ListTile(
title: Text(
"地址:00000000",
style: TextStyle(
fontSize: 20
),
),
),
],
),
)
],
);
}
}
import 'package:flutter/material.dart';
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("按钮"), // 标题
leading: Icon(Icons.menu), // 左侧图标
actions: [Icon(Icons.settings)], // 右侧图标数组
elevation: 0.0,// 去掉阴影
centerTitle: true, // 标题居中
),
body:ButtonDemo(),
// 漂浮按钮
floatingActionButton: FloatingActionButton(
onPressed: (){},
tooltip: 'Increment',
child: Icon(Icons.add),
backgroundColor: Colors.green,
elevation: 0,
),
);
}
}
class ButtonDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.all(10),
child: Wrap(
children: [
TextButton(
onPressed: (){
print('点击TextButton');
},
onLongPress: (){
print("长按TextButton");
},
child: Text("TextButton")
),
ElevatedButton(
onPressed: (){
print('点击ElevatedButton');
},
onLongPress: (){
print("长按ElevatedButton");
},
child: Text("ElevatedButton")
),
OutlinedButton(
onPressed: (){
print('点击OutlineButton');
},
onLongPress: (){
print("长按OutlineButton");
},
child: Text("轮廓按钮"),
style: ButtonStyle(
textStyle: MaterialStateProperty.all(
TextStyle(
fontSize: 30,
)
),
foregroundColor: MaterialStateProperty.resolveWith((states) => null),
shadowColor: MaterialStateProperty.all(Colors.yellow),
elevation: MaterialStateProperty.all(20),
side: MaterialStateProperty.all(
BorderSide(
color: Colors.green,
width:2
)
),
// 声明按钮形状
shape: MaterialStateProperty.all(
StadiumBorder(
side: BorderSide(
color:Colors.green,
width:2,
)
)
),
// 设置按钮大小
minimumSize: MaterialStateProperty.all(Size(150, 60)),
// 水波纹
overlayColor: MaterialStateProperty.all(Colors.purple),
),
),
// 图标按钮
IconButton(
icon: Icon(Icons.add_alarm),
onPressed: (){
print("IconButton");
},
color:Colors.red,
splashColor: Colors.lightBlue, // 水波纹
//highlightColor: Colors.purple, // 高亮
tooltip: "怎么了", // 提示
),
TextButton.icon(
onPressed: null,
icon: Icon(Icons.add_circle),
label: Text("文本按钮"),
),
ElevatedButton.icon(
onPressed: null,
icon: Icon(Icons.add_circle),
label: Text("凸起按钮"),
),
OutlinedButton.icon(
onPressed: null,
icon: Icon(Icons.add_circle),
label: Text("轮廓按钮")
),
Container(
color:Colors.pink[100],
width: double.infinity,
child: ButtonBar(
children: [
ElevatedButton(onPressed: null, child: Text('按钮1')),
ElevatedButton(onPressed: null, child: Text('按钮2')),
ElevatedButton(onPressed: null, child: Text('按钮3')),
ElevatedButton(onPressed: null, child: Text('按钮4')),
],
),
),
BackButton(
color: Colors.red,
onPressed: (){},
),
CloseButton(
color:Colors.red,
)
],
),
);
}
}
import 'package:flutter/material.dart';
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("图片"), // 标题
leading: Icon(Icons.menu), // 左侧图标
actions: [Icon(Icons.settings)], // 右侧图标数组
elevation: 0.0,// 去掉阴影
centerTitle: true, // 标题居中
),
body:ImageDemo()
);
}
}
class ImageDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: [
Image.asset(
'images/men.png',
width: 200,
height: 200,
fit:BoxFit.fill
),
// 加载网络图片
Image.network(
'https://pics6.baidu.com/feed/2934349b033b5bb58fd9cb87820fab3eb700bca5.jpeg?token=0628702156d2f7935788cbfdccdbafa4',
repeat: ImageRepeat.repeat,
// 混合颜色
colorBlendMode: BlendMode.colorBurn,
color: Colors.green,
)
],
);
}
}