我的CloseButton Widget不愿意进入行内并在textBaseLine(文本下方的绿色线)上正确对齐
最小代码:
Container(
color: Colors.red,
height: 20.h,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'request_card_for'.tr(),
style: Theme.of(context).textTheme.headline5?.copyWith(
fontSize: 14.sp, fontWeight: FontWeight.w600),
),
const CloseButtonWidget()
],
),
),
screen shot of the issue
我试过了CrossAxisAlign行内构件
使CloseButton小部件居中
... and nevermind fix it lol.
class CloseButtonWidget extends StatelessWidget {
const CloseButtonWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return IconButton(
**padding: EdgeInsets.zero,** // <--- Fix... iconButton has default padding of .all(8.0), which caused misaligning of IconButton in Row for me
onPressed: () {
AutoRouter.of(context).pop();
},
icon: Icon(
Icons.close,
color: Theme.of(context).primaryColor,
size: 18,
),
);
}
}
编辑:无法找到这从一个快速谷歌搜索,所以把它留在这里,也许它会帮助别人面临同样的问题
1条答案
按热度按时间4jb9z9bj1#
这工作(更清楚地了解)