全局:
设置AppBar的主题中的toolbarHeight
。
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: "Flutter Demo",
debugShowCheckedModeBanner: false,
home: HYHomePage(),
theme: ThemeData(
appBarTheme: AppBarTheme(
color: Tcolor.SelectedColor,
toolbarHeight: 50
)
),
);
}
局部:
法一:使用属性:toolbarHeight
法二:在需要的AppBar外面封装PreferredSize
,
@override
Widget build(BuildContext context) {
final logic = Get.put(AddTaskLogic());
final state = Get.find<AddTaskLogic>().state;
return Scaffold(
appBar: PreferredSize (
preferredSize: Size(double.infinity, 30),
child: AppBar(
// toolbarHeight: 40,
backgroundColor: Tcolor.barBackgroudColor,
elevation: 0,
),
),
body: _addTaskContent(state,context),
);
}