相关疑难解决方法(0)

Flutter SnackBar 未显示

我已经实现了一个提交表单的功能。我想在提交后有 SnackBar Alert。我试过了,但它不起作用。添加 SnackBar 路由后也不起作用。

addTicket() async {
if (_formKey.currentState.validate()) {
  _formKey.currentState.save();

  try{
    DocumentReference ref = await db.collection('CostalLineTicketDetails').
    document(ticketCato).collection("Tickets").add(
        {
          'startStation':startStation,
          'endStation':endStation,
          'price':price,
          'ticketType':ticketCato,
          'contactNo':contactNo,
          'dateTime':dateTime,
        });
    setState(() => id = ref.documentID);
    Navigator.push(context, new MaterialPageRoute(builder: (context) => CostalLine()));

    Scaffold.of(context).showSnackBar(SnackBar(content: Text('Ticket Added Sucessfully')));

  }catch(e){
    print(e);
  }
}
Run Code Online (Sandbox Code Playgroud)

} }

android flutter

2
推荐指数
1
解决办法
4011
查看次数

标签 统计

android ×1

flutter ×1