Search code examples
flutterdartlistview

An argument for the parameter named 'subtitle' has already been specified. Try removing one of the named arguments. or edit one of the names


I want to add text to ListView. But when I add another subtitle it doesn't run and I change to new arguments it doesn't run.

 return ListView.builder(
                        itemCount: problemlist.length,
                        itemBuilder: ((context, index) {
                          problemModel problem = problemlist[index];
                          return Card(
                            margin: EdgeInsets.all(10),
                            child: ListTile(
                              title: Text(
                                problem.name_surname,
                                style: TextStyle(
                                    fontWeight: FontWeight.bold, fontSize: 19),
                              ),
                              subtitle: Text(
                                problem.address,
                                style: TextStyle(
                                    fontWeight: FontWeight.bold, fontSize: 17),
                              ),
                              trailing: Text(
                                problem.status,
                               style: TextStyle(
                                    fontWeight: FontWeight.bold, fontSize: 16),
                             ),
                              subtitle: Text(
                                problem.address,
                                style: TextStyle(
                                    fontWeight: FontWeight.bold, fontSize: 17),
                              ),
                            ),
                          );
                        }));

ERROR The argument for the named parameter 'subtitle' was already specified. Try removing one of the named arguments, or correcting one of the names to reference a different named parameter.


Solution

  • In ListTile you're defining subtitle twice

    ListTile(
      title: ...,
      subtitle: ...,
      trailing: ...,
      subtitle: ...,
    )
    

    It should be:

    ListTile(
      title: ...,
      subtitle: ...,
      trailing: ...,
    )