skip to Main Content
<kbd>
class _SearchState extends State<Search> {
  TextEditingController searchController = TextEditingController();
  Future<QuerySnapshot> searchResultsFuture; //The problem is here


  handleSearch(String query) {
    Future<QuerySnapshot> user =
        usersRef.where("displayName", isGreaterThanOrEqualTo: query).get();
    //.getDocuments()
    setState(() {
      searchResultsFuture = user;
    });
  }

</kbd>

Have used late Future searchResultsFuture;
and the highlighted error gone but the code didn’t work

2

Answers


  1. use ? operator after QuerySnapshot or after this ( > )

    Login or Signup to reply.
  2. Change

    Future<QuerySnapshot> searchResultsFuture;
    

    to

    Future<QuerySnapshot>? searchResultsFuture;
    

    to make it nullable

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search