dart
复制代码
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
//所有右侧行为按钮
List<Widget> actionList = const [
Icon(Icons.social_distance),
SizedBox(
width: 30,
),
Icon(Icons.cyclone),
SizedBox(
width: 30,
),
Icon(Icons.manage_accounts),
SizedBox(
width: 40,
)
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary, //背景颜色
foregroundColor: const Color.fromARGB(135, 226, 5, 255),
leading: const Icon(Icons.accessibility_new_rounded), //左侧按钮
title: const Text("Flutter 示例"), //标题
actions: actionList, //右侧按钮
elevation: 10, //下方阴影
shadowColor: const Color.fromARGB(136, 0, 225, 255), //阴影颜色
centerTitle: true, // 标题是否居中(ios默认居中,Android默认居左)
surfaceTintColor: const Color.fromARGB(172, 249, 128, 0), //表面颜色
toolbarHeight: 45, //顶部栏高度
iconTheme: const IconThemeData(
size: 30, color: Color.fromARGB(207, 255, 251, 0)), //控制内部元素样式
primary: true, // 是否显示主要按钮
titleSpacing: 100, //标题内边距
bottom: const TabBar(tabs: [
Tab(icon: Icon(Icons.directions_car)),
Tab(icon: Icon(Icons.directions_transit)),
Tab(icon: Icon(Icons.directions_bike)),
]), //顶部栏底部按钮
shape:const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(15)
) //顶部栏底部按钮样式
),
), //顶部栏
body: Center(
child: ListView(
children: [],
),
),
);
}
}