
文本与按钮
//导入Material UI 组件库
import 'package:flutter/material.dart';
//程序入口
void main() {
runApp(const MaterialApp(home: TxtBtn()));
}
//文本与按钮
class TxtBtn extends StatelessWidget {
const TxtBtn({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("TxtBtn"),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Text(
"常规文本",
maxLines: 1,
style: TextStyle(color: Colors.deepOrange, fontFamily: "Schyler"),
),
const Text.rich(TextSpan(children: [
TextSpan(
text: "AA",
style: TextStyle(color: Colors.cyan),
),
TextSpan(
text: "BB",
style: TextStyle(color: Colors.brown),
),
])),
//间隔填充
const SizedBox(
height: 10,
),
//漂浮按钮阴影背景
ElevatedButton(
child: const Text("ElevatedButton"),
onPressed: () {},
),
//文本按钮透明
TextButton(
child: const Text("TextButton"),
onPressed: () {},
),
//边框按钮
OutlinedButton(
child: const Text("OutlinedButton"),
onPressed: () {},
),
FloatingActionButton(
backgroundColor: Colors.deepOrange,
child: const Icon(Icons.add),
onPressed: () {}),
IconButton(
icon: const Icon(Icons.thumb_up),
onPressed: () {},
),
//图标按钮
ElevatedButton.icon(
icon: const Icon(Icons.send),
label: const Text("ElevatedButton"),
onPressed: () {},
),
OutlinedButton.icon(
icon: const Icon(Icons.add),
label: const Text("OutlinedButton"),
onPressed: () {},
),
TextButton.icon(
icon: const Icon(Icons.info),
label: const Text("TextButton"),
onPressed: () {},
),
],
),
);
}
}
网友评论