[NewGroupChatScreen] Maintain selectedUsersList when going back and forward in the flow

This commit is contained in:
xsahil03x
2020-11-23 20:40:09 +05:30
parent 0a9652f1ac
commit 515b9734cb
3 changed files with 168 additions and 155 deletions
+8 -2
View File
@@ -53,7 +53,12 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
return WillPopScope(
onWillPop: () async {
Navigator.pop(context, _selectedUsers);
return false;
},
child: Scaffold(
backgroundColor: Color.fromRGBO(252, 252, 252, 1),
appBar: AppBar(
elevation: 1,
@@ -205,7 +210,7 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
_selectedUsers.remove(user);
});
if (_selectedUsers.isEmpty) {
Navigator.pop(context);
Navigator.pop(context, _selectedUsers);
}
},
),
@@ -215,6 +220,7 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
),
],
),
),
);
}
}
+9 -2
View File
@@ -69,8 +69,8 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
StreamIcons.arrow_right,
color: Color(0xFF006CFF),
),
onPressed: () {
Navigator.push(
onPressed: () async {
final updatedList = await Navigator.push(
context,
MaterialPageRoute(
builder: (_) => GroupChatDetailsScreen(
@@ -78,6 +78,13 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
),
),
);
if (updatedList != null) {
setState(() {
_selectedUsers
..clear()
..addAll(updatedList);
});
}
},
)
],
+1 -1
View File
@@ -33,7 +33,7 @@ class StreamBackButton extends StatelessWidget {
if (onPressed != null) {
onPressed();
} else {
Navigator.of(context).pop();
Navigator.maybePop(context);
}
},
child: Icon(