0

I want to show a alert when this button is pressed but this alertdialog is not working. I am using await to add data to firestore and after that i want to display an alert box.

onPressed: () async {
                          
                          
                         
                          await firestoreInstance
                              .collection('favs')
                              .document(snapshot.data['id'])
                              .setData(
                            {
                              'uid': snapshot.data['uid'],
                              'id': snapshot.data['id'],
                              'title': snapshot.data['title'],
                              'description': snapshot.data['description'],
                              'duration': snapshot.data['duration'],
                              'members': snapshot.data['members'],
                              'complexity': snapshot.data['complexity'],
                              'affordability': snapshot.data['affordability'],
                              'prequisites': snapshot.data['prequisites'],
                              'contact': snapshot.data['contact'],
                              'imageurl': snapshot.data['imageurl'],
                            },
                          );
                          
                           AlertDialog(title: Text('added to favs!'),);
                        },

1 Answers1

1

you need to use the showDialog method to display an AlertDialog

showDialog(
      context: context,
      builder: (_){
        return AlertDialog(title: Text('added to favs!'),);
      },
    );
JideGuru
  • 7,102
  • 6
  • 26
  • 48