我嘗試顯示一個ExpansionTile,其中包含一些文本,后跟一個影像。參考螢屏截圖,您可以看到兩個小部件之間有一些空間。有人知道我可以如何減少這個空間嗎?

class Test extends StatelessWidget {
const Test({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: backGround,
appBar: AppBar(
title: const Text('Aromatics'),
backgroundColor: appbarColor,
),
body: Column(
children: [
ExpansionTile(
iconColor: titleColor,
title: const Text('Tst', style: TextStyle(color: titleColor)),
subtitle: const Text('Test subtitle',
style: TextStyle(color: Colors.white)),
children: [
Container(
margin: const EdgeInsets.only(left: 20),
child: Column(
children: const [
Text('Test text',
style:
TextStyle(color: Colors.white, fontSize: 13)),
],
),
),
]),
const SizedBox(
height: 1,
),
Expanded(
child: Image.asset('assets/images/test.webp'),
),
],
));
}
}
uj5u.com熱心網友回復:
根據ExpansionTile Doc,您可以childrenPadding用來管理子小部件的填充
指定子元素的填充。如果此屬性為 null,則使用 E??xpansionTileThemeData.childrenPadding。如果這也是 null 則 childrenPadding 的值為 EdgeInsets.zero。
uj5u.com熱心網友回復:
洗掉不Expanded適合您的目標嗎?
...
const SizedBox(
height: 1,
),
Image.asset('assets/images/test.webp'),
...
uj5u.com熱心網友回復:
只需洗掉Expanded影像周圍的小部件,因為它占用了影像中的所有剩余空間Column。
當前代碼:
Column(
children: [
...
Expanded(
child: Image.asset('assets/images/test.webp'),
),
...
],
),
新代碼:
Column(
children: [
...
Image.asset('assets/images/test.webp'),
...
],
),```
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/485305.html
上一篇:重新編譯給出錯誤不平衡括號
