Dismissible Widget In Flutter

Updated 5 January 2024

Save

You can wrap a widget as a child of Dismissible in Flutter if you need to construct a dismissible widget. Rejectable Typically, a widget in Flutter is used to wrap each list item, either vertically or horizontally, allowing it to be dismissed. I’ll walk you through a few instances of using the widget, such as displaying the confirmation dialog, customizing the backdrop that appears when the child is dismissed, and defining the dismiss direction.

You can also check out our Flutter app development services for more Flutter app development.

widget that can be dismissed by dragging in the indicated direction. Dragging or flinging this widget in the DismissDirection causes the child to slide out of view.

Let’s focus on the Dismissible Widget In Flutter

Properties

Here’s the list of properties  Dismissible you can pass to the constructor.

Both the child (Widget) and the key (Key) must be supplied. The key becomes essential since the widget may be removed from the widget list. If there are multiple dismissible widgets, make sure each one has a unique key. Since dismissing one widget may change the index of other widgets, avoid using the index as a key. child is the second required property, and passing a dismissible widget is required.

The onDismissed property is another crucial one. It’s a callback function that takes one DismissDirection parameter.

We’re going to use this data

Dismissible Widget Code

Here’s the code for building the ListView

The Dismissible is the output of the itemBuilder, which constructs the list items. Apart from the mandatory parameters (key and child), the onDismissed callback is additionally given. You can see how to specify various actions for each direction by looking at the example below.

Final Code

That’s all for this Article.

Conclusion

We learned about the Dismissible Widget in Flutter in this blog.

Visit the link for additional information on the Dismissible Widget in Flutter.

Thanks for reading this blog. You can also check other blogs from here for more knowledge.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home