【发布时间】:2021-11-29 00:04:39
【问题描述】:
我的目标
我想以 ListTile 作为内容显示 Flutter 的 default SnackBar。
问题
由于某种原因,Snackbar 几乎比我想要的高三倍,并且似乎 Snackbar 中没有设置高度的参数。
我检查了类似的questions,没有找到一个有效的例子。
小吃店
void showSuccessSnackBar({BuildContext context, String message}) {
Scaffold.of(context).showSnackBar(
SnackBar(
content: Container(
child: ListTile(
leading: _successIcon(),
dense: true,
title: Text(
message,
textAlign: TextAlign.center,
style: TextStyle(
color: HATheme.HOPAUT_PINK,
fontWeight: FontWeight.bold
),
)),
),
behavior: SnackBarBehavior.floating,
duration: Duration(seconds: 3),
backgroundColor: Colors.white));
}
Widget _successIcon() {
return Image.asset(
'assets/icons/success.png',
// resizing this doesn't help
height: 30,
width: 30,
);
}
我想要的尺寸:
实际尺寸:
【问题讨论】:
-
请添加您的代码
-
忘记了最重要的(facepalm),再检查一遍