Search code examples
flutterdart

When I use row in listview trailing it doesn't work without specific width


When I use row in listview trailing it work but leading hide and trailing overflow

ListTile(
                    title: Text(state.users[index].name),
                    subtitle: Text(state.users[index].email),
                    trailing: SizedBox(
                      width: 50,
                      child: Row(
                        children: [
                          InkWell(
                            onTap: () {
                              name.text = state.users[index].name;
                              name.text = state.users[index].email;
                              showBottomSheet(
                                  id: state.users[index].id,
                                  context: context,
                                  isEdit: true,
                                  userListBloc: userListBloc);
                            },
                            child: const Icon(Icons.edit),
                          ),
                          //SizedBox(height: 10,),
                          InkWell(
                            onTap: () {
                              userListBloc.add(DeleteUser(state.users[index]));
                            },
                            child: const Icon(
                              Icons.delete,
                            ),
                          )
                        ],
                      ),
                    ),
                  ),

In add specific width but don't want to add without add width it's work if yes than how?


Solution

  • Try below code with both leading and trailing data. Hope it helps

                 ListTile(
                      title: Text("name"),
                      subtitle: Text("email"),
                      leading: Text("leading text"), // your widget
                      trailing: Row(
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          InkWell(
                            onTap: () {},
                            child: const Icon(Icons.edit),
                          ),
                          //SizedBox(height: 10,),
                          InkWell(
                            onTap: () {},
                            child: const Icon(
                              Icons.delete,
                            ),
                          )
                        ],
                      ));