我想创建一个简单的快餐栏,来自屏幕顶部的bottom.In flutter,我已经使用了本地快餐栏,但它没有这样的功能。
发布于 2019-01-15 16:36:30
您可以使用https://pub.dartlang.org/packages/flushbar
RaisedButton(
child: Text('Show Top Snackbar'),
onPressed: () {
Flushbar(
flushbarPosition: FlushbarPosition.TOP,
)
..title = "Hey Ninja"
..message = "Lorem Ipsum is simply dummy text of the printing and typesetting industry"
..duration = Duration(seconds: 3)
..show(context);
},
),发布于 2021-10-16 01:35:00
您可以使用设备的高度来设置边距,以实现以下目的:
ScaffoldMessenger.of(context).showSnackBar(new SnackBar(
content: Text('Snackbar message'),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
margin: EdgeInsets.only(
bottom: MediaQuery.of(context).size.height - 100,
right: 20,
left: 20),
));发布于 2021-01-26 02:52:48
2021年1月也可以使用Getx包- https://pub.dev/packages/get
只需使用代码即可
Get.snackbar(
'message',
'message body',
onTap: (_) => DoSomething(),
duration: Duration(seconds: 4),
animationDuration: Duration(milliseconds: 800),
snackPosition: SnackPosition.TOP,
);奖励:)你可以在没有上下文的情况下调用它--从控制器,函数,块等等。
https://stackoverflow.com/questions/54194999
复制相似问题