Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
Flutter problem with display searching form firebase. Too many positional arguments

Hello I have a problem with my code. I want to display a list of a users from firebase, but im stuck at the end. the line of code shuld look like this:

userName: searchSnapshopt.documents[index].data["name"]);

but after the update, there are no documents anymore and there is "docs" and it breaks everything down for me

here is my code

class _SearchScrState extends State<SearchScr> {
  DatabaseMethods databaseMethods = new DatabaseMethods();
  TextEditingController searchTextEditingController =
      new TextEditingController();

  QuerySnapshot searchSnapshopt;

  initiateSearch() {
    databaseMethods
        .getUserByUsername(searchTextEditingController.text)
        .then((val) {
      setState(() {
        searchSnapshopt = val;
      });
    });
  }

  Widget searchList() {
    return searchSnapshopt != null
        ? ListView.builder(
            itemCount: searchSnapshopt.docChanges.length,
            shrinkWrap: true,
            itemBuilder: (context, index) {
              return SearchTile(
                  userName: searchSnapshopt.docs[0].data("name"));
            })
        : Container();
  }

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Ok i have a solution, just change this

userName: searchSnapshopt.docs[index].data("name")

to this:

userName: searchSnapshopt.docs[index].get("name")

and now works

about 4 years ago · Juan Pablo Isaza Report

0

Try this:

class _SearchScrState extends State<SearchScr> {
  DatabaseMethods databaseMethods = new DatabaseMethods();
  TextEditingController searchTextEditingController =
      new TextEditingController();

  QuerySnapshot searchSnapshopt;

  initiateSearch() {
    databaseMethods
        .getUserByUsername(searchTextEditingController.text)
        .then((val) {
      setState(() {
        searchSnapshopt = val;
      });
    });
  }

  Widget searchList() {
    return searchSnapshopt != null
        ? ListView.builder(
            itemCount: searchSnapshopt.docChanges.length,
            shrinkWrap: true,
            itemBuilder: (context, index) {
              return SearchTile(
                  userName: searchSnapshopt.docs[index].get("name"));
            })
        : Container();
  }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!