[英]How to align TextButton's icon to right in Flutter?
我認為根據此處<\/a>的文檔和我的知識,圖標不是右側位置,但您使用Directionality()<\/strong>小部件已解決只需您使用ElevetedBtton.icon<\/strong>而不是TextButton.icon<\/strong>並且它工作正常並且您使用Directionality()<\/strong>小部件參考下面的代碼希望對您有所幫助。
通過Directionality()<\/strong>小部件使用 ElevetedBtton.icon
使用 TextButton.icon<\/blockquote>
通過Directionality()<\/strong>小部件使用 TextButton.icon<\/blockquote>您的屏幕使用 ElevetedBtton.icon 小部件,例如 -> <\/a>
您的屏幕使用 TextButton.icon 小部件,例如 ->
您的屏幕使用 TextButton.icon 使用 Directionality() 的小部件,例如 ->
TextButton.icon(
onPressed:null,
icon: Text('2022-01-27'),
label: Icon(Icons.arrow_drop_down_sharp),
)
Directionality(
textDirection: TextDirection.rtl,
child: TextButton.icon(
onPressed: () {
Navigator.pushNamed(context, Routes.checkout);
},
icon: const Icon(IcoFontIcons.arrowRight),
label: const Text(
"Chekout",
style: TextStyle(color: Colors.blue),
),
),
)
您可以使用
Directionality<\/code>小部件包裝小部件。
此小部件可以將給定的文本方向應用於子小部件。 使用文本按鈕可以執行以下操作:
Directionality(
textDirection: TextDirection.rtl,
child: TextButton.icon(
onPressed: onPressed,
icon: Icon(
Icons.arrowOpen,
color: companySelectionColor,
),
label: text,
),
);
您可以嘗試使用
IconButton<\/code>並將 Text 小部件添加為子小部件。
IconButton(
icon: Icon(Icons.arrowOpen),
iconSize: 12,
onPressed: () {},
),
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.