gpt4 book ai didi

dart - 如何在Flutter中将 snackbar 设置得非常低?

转载 作者:行者123 更新时间:2023-12-03 04:02:01 33 4
gpt4 key购买 nike

如何在SnackBar上设置高度,以及如何在SnackBar上以文本为中心?我也使用了Positioned和SozedBox。
enter image description here

  _showSnackBar(GlobalKey<ScaffoldState> _scaffoldKey) {
final snackBar = SnackBar(
content:SizedBox(child:Container(
child: Center(
child: Text("Connection dropped.", style:
TextStyle(color: Colors.white,fontWeight: FontWeight.bold),textAlign: TextAlign.center,)),height: 1.0),),
duration: Duration(seconds: 10),
backgroundColor: Colors.red,
);
_scaffoldKey.currentState.showSnackBar(snackBar);
}

最佳答案

只需执行以下操作:

final snackBar = SnackBar(
content: Container(
height: 50.0,
child: Center(
child: Text(
"Connection dropped.",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
)),
),
duration: Duration(seconds: 10),
backgroundColor: Colors.red,
);
_scaffoldKey.currentState
.showSnackBar(snackBar);

关于dart - 如何在Flutter中将 snackbar 设置得非常低?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55096418/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com