我嘗試在 SizedBox-widget 中對齊兩行,現在看起來不應該有溢位,但有一個。
這是代碼,它現在的樣子在下面。
SizedBox(
height: MediaQuery.of(context).size.height * 0.1,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
//Profile
Expanded(
child: Row(
children: [
OutlinedButton(
onPressed: () => {Navigator.push(context,
MaterialPageRoute(builder: (_) => const Profile()))
},
style: OutlinedButton.styleFrom(
shape: const CircleBorder(),
padding: const EdgeInsets.all(2)
),
child: CircleAvatar(
backgroundColor: primary,
backgroundImage: NetworkImage(profilePath),
radius: 24,
)
),
//rowSpacer,
Text(profileName, style: categoryNF),
],),
),
// Likes
Expanded(
child: Row (
mainAxisAlignment: MainAxisAlignment.end,
children: [
IconButton(
onPressed: () => {},
icon: const Icon(
Icons.favorite_border,
size: 32,
color: Colors.redAccent,
),
),
//rowSpacer,
Text("$likes Likes", style: categoryNF),
],)
),
],
),
),

uj5u.com熱心網友回復:
Text嘗試用這樣的小部件包裝你的名字Expanded:
Expanded(child: Text(profileName, style: categoryNF),),

uj5u.com熱心網友回復:
我不完全確定您在問什么,但聽起來您想知道如何修復代碼中的“正確溢位 39 像素”錯誤。
解決此問題的最簡單方法是在行的右側添加一個填充。例如:
Row(
padding: EdgeInsets.only(right: 16.0), // add this
children: [
// your widgets here
],
),
這將在行的右側添加 16 像素的填充,這足以修復溢位錯誤。
uj5u.com熱心網友回復:
使用這個Text(profileName,overflow: TextOverflow.ellipsis, style: categoryNF)更多參考這個答案
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/515991.html
標籤:扑镖颤振布局
上一篇:為什么螢屏不更新?
