我在这里有问题。如何使用 FLutter Getx 换屏。我从firestore得到了那个searchUser的GetxControll。这是代码。
class AuthenticationC extends GetxController {
final usersRef = FirebaseFirestore.instance.collection('Users');
List<QueryDocumentSnapshot> searchResultFuture;
searchUser(String query) async {
QuerySnapshot snapshot = await usersRef
.where('DisplayName', isGreaterThanOrEqualTo: query)
.get();
searchResultFuture = snapshot.docs;
return snapshot.docs;
}
}
然后我想将 UI 从 buildNoContent() 更改为 With buildSearchedContent()。当用户在 TextField 中输入文本时。然后它将自动更改用户界面。我已经得到了 searchUser,但 UI 没有改变。这里是 UI 代码。谢谢你
class SearchUserScreen extends StatelessWidget {
final authenticationC = AuthenticationC.to;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
searchBox(),
SizedBox(
height: 20,
),
authenticationC.searchResultFuture == null // i want to change here
? buildNoContent() // im already using GetBuilder<AuthenticationC>
: Expanded(child: buildSearchedContent(),// But it wont change
),
],
),
),
}
}