问题描述
在Android上(我不知道IOS怎么办),有时您会看到一个小的浅灰色圆形框,并在屏幕的底部中央显示一条消息。就像Google翻译应用中的“音量已关闭”一样。我已经在许多其他应用程序中看到了此功能,因此我认为它已包含在材料设计中。 Flutter框架中是否有此功能的实现?
解决方法
我认为软件包fluttertoast是您所需要的。这是一个有关如何使用它的简单示例:
代码
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget.title)),body: Center(
child: RaisedButton(
child: Text('Show toast'),onPressed: () => Fluttertoast.showToast(
msg: "This is a short message",toastLength: Toast.LENGTH_SHORT,textColor: Colors.black,fontSize: 16,backgroundColor: Colors.grey[200],),);
}
}
屏幕截图