List<String> members = [user.uid];
final TextEditingController _searchController = TextEditingController();
return Material(
child: Container(
child: AspectRatio(
aspectRatio: 3 / 2,
child: Container(
color: Colors.white,
child: Column(
children: [
groupNameField(_groupNameController),
groupAvatarField(_groupAvatarController),
Row(children: [
searchField(_searchController, members),
IconButton(
icon: Icon(Icons.search),
onPressed: () async {
var s = SearchUserUtil();
var searchRes =
await s.searchUser(_searchController.text);
if (searchRes != null) {
setState(() {
members.add(searchRes);
});
_searchController.clear();
}
//print(await s.searchUser(_searchController.text));
else
print("User doesnt exists");
print(members);
},
),
]),
Expanded(
child: ListView.builder(
itemCount: members.length,
itemBuilder: (BuildContext context, int index) {
print(index);
return Text(members[index]);
},
),
)
],
),
),
),
),
);
}
}
Widget searchField(
TextEditingController _searchController, List<String> members) {
return Container(
width: 500,
child: TextFormField(
controller: _searchController,
decoration: InputDecoration(
prefixIcon: Icon(
Icons.email,
color: Color(0xFF4A41AE),
),
errorText: null,
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Color(0xFF4A41AE),
),
),
hintText: "Search by email",
labelStyle: TextStyle(
fontSize: 14,
color: Color(0xFF4A41AE),
),
border: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFF4A41AE)),
),
),
),
);
}
So in the members list, the only thing that's in it is the current user's uid(via the first line). Now my problem is that when I search the user, if its found, it adds it to the list but doesn't display it on the list view. I added print statements to try and debug and found that the index doesn't change and it also seems like w/e is added to the list doesn't save. I'm not sure what the problem is but if anyone can help me I'd appreciate it. Thanks!