Skip to content

Commit

Permalink
fixed change_username.dart not changing it in db
Browse files Browse the repository at this point in the history
  • Loading branch information
deargosep committed Jan 25, 2022
1 parent bdb5680 commit 7ecf49e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/screens/change_username.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ class ChangeUsernameScreen extends HookWidget {
final name = useTextEditingController();
void submit() {
FirebaseAuth.instance.currentUser?.updateDisplayName(name.value.text);
var data = {"name": name.value.text};
final uid = FirebaseAuth.instance.currentUser?.uid;
var docId = '';
FirebaseFirestore.instance
.collection('Users')
.where('uid', isEqualTo: uid)
.get()
.then((value) => docId = value.docs.first.id);
FirebaseFirestore.instance.collection('Users').doc(docId).update(data);
Get.back();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/screens/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ChatScreen extends HookWidget {
return Container();
}

var params = {"id": id, "name": data['name'].toString()};
// var params = {"id": id, "name": data['name'].toString()};
// return Container(
// child: Text(data['text']),
// // title: Text(data['text']),
Expand Down

0 comments on commit 7ecf49e

Please sign in to comment.