0

I want this type of behavior in list view item swipe.

  1. When user swipe half the list item I want to show some options.
  2. When user click on that option I am performing some task.
  3. When a user swipes an item all the way through to end(mean full swipe), I don't want to remove it; instead, I want to perform a task, and when that task or process is finished, I want to dismiss the swipe.

Here is my Code!

child: SlidableAutoCloseBehavior(

              child: ListView.separated(
                itemBuilder: ((context, index) => Slidable(
                    closeOnScroll: true,
                    key: UniqueKey(),
                    startActionPane: ActionPane(
                      dismissible: DismissiblePane(
                        onDismissed: () {
                          Fluttertoast.showToast(
                              msg: "Full swipe ${index + 1}");
                       
                        },
                      ),
                      motion: BehindMotion(),
                      children: [
                        SlidableAction(
                            onPressed: (BuildContext context) {
                              Fluttertoast.showToast(
                                  msg: "Unlock ${index + 1}");
                            },
                            backgroundColor: Colors.red,
                            label: "Unlock",
                            icon: Icons.lock_open),
                        SlidableAction(
                            onPressed: (BuildContext context) {
                              Fluttertoast.showToast(msg: "Lock ${index + 1}");
                            },
                            backgroundColor: Colors.green,
                            label: "Lock",
                            icon: Icons.lock_outline),
                      ],
                    ),
                    child: listViewItem(index))),
                separatorBuilder: (BuildContext context, int index) =>
                    const Divider(),
                itemCount: list.length,
              ),
            )

I had accomplished the first and second points successfully, but I have no idea how to archive the third point.

Mohammad Taqi
  • 161
  • 2
  • 8
  • Would this help: https://pub.dev/packages/flutter_slidable – Andrija Jan 11 '23 at 10:26
  • I did utilize that package here. Check the code, please. – Mohammad Taqi Jan 11 '23 at 10:28
  • Sorry, didn't realize as there are no import statement. Let me look again. – Andrija Jan 11 '23 at 10:34
  • oky let me add that! so other can recognize it. – Mohammad Taqi Jan 11 '23 at 10:56
  • I suggest you look at what the scroll controller property of listview can do for you. Also this SO post https://stackoverflow.com/questions/46377779/how-to-check-if-scroll-position-is-at-top-or-bottom-in-listview – GrahamD Jan 11 '23 at 14:01
  • I am taking about swipe .. not scrolling... When user swipe the item fully to from left tk right I want to perform task but here it removes item from list. If you want I'll edit the question with video so you can understand. – Mohammad Taqi Jan 11 '23 at 18:27

0 Answers0