1

I use flutter_slidable: ^0.6.0. I hope working only one item slidable in my listview.
if one item slide by user, all the others(whatever open or close) r closed. some docs say use key.but mine is not working.

 return ListView.builder(
            physics: ClampingScrollPhysics(),
            itemCount: snapshot.data!.size,
            shrinkWrap: true,
            itemBuilder: (BuildContext context, count) {
             

              return Padding(
                padding: const EdgeInsets.all(8.0),
                child: Slidable(
                  key: Key(snapshot.data!.docs[count].id),
                  controller: slidableController,
                  actionPane: SlidableDrawerActionPane(),
                  actionExtentRatio: 0.25,
                  actions: <Widget>[
                    widget.pin == 0
                        ? IconSlideAction(
                            caption: 'pin 제거',
                            color: Colors.black45,
                            icon: Icons.push_pin_rounded,
                            onTap: () {
                              pinEraseRoom(widget.roomId);
                            },
                          )
                        : IconSlideAction(
                            caption: 'Pin',
                            color: Colors.black45,
                            icon: Icons.push_pin_outlined,
                            onTap: () {
                              pinRoom(widget.roomId);
                            },
                          ),
                  ],
                  secondaryActions: <Widget>[
                    IconSlideAction(
                      caption: 'Delete',
                      color: Colors.red,
                      icon: Icons.delete,
                      onTap: () {
                        deleteRoom(widget.roomId);
                      },
                    ),
                  ],

mine https://i.stack.imgur.com/eFW7J.jpg

1 Answers1

1

resolved

/// parent         
              return StreamBuilder<DocumentSnapshot>(
                                   stream:      FirebaseFirestore.instance
                                        .collection('users')
                                        .doc(other)
                                        .snapshots(),
                                   builder: (context, snapshot) {
                                      if (!snapshot.hasData) {
                                        return Container();
                                      }
                                     return ConversationList(
                                     controller: slidableController,

//////// child widget in coversationList widget

       itemBuilder: (BuildContext context, count) {
                  return Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Slidable(
                      key: Key(snapshot.data!.docs[count].id),
                      controller: widget.controller,
                      actionPane: SlidableDrawerActionPane(),
                      actionExtentRatio: 0.25,
                      actions: <Widget>[
                        widget.pin == 0

// More clarity can be found here

Darsh Shah
  • 1,526
  • 1
  • 11
  • 20