Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I used Dismissible() when the child have BorderRadius()?

Tags:

flutter

I am trying to use Dismissible in a Container with BorderRadius but the onDismissed Animation don't work properly, because the back ground don't have the same shape.

This is a screen shot of the problem.

I have tried this:

 Stack(
     overflow: Overflow.clip,
     children: <Widget>[
         MyBackgroundWidget(), // instead of background
         Dismissible(
             child: MyForegroundWidget(),
             // no background
         )
     ],
 );

and that works if you don't have padding. But don't work in my case, because i have padding in my container. So it will look like this when onDismissed, before the animation its completely done.

like image 498
Andres Diaz Avatar asked Nov 19 '19 19:11

Andres Diaz


People also ask

What is key in dismissible flutter?

Key — Each Dismissible widget should contain a Key to uniquely identify widgets. Background — The background of an item is set to red while performing dismissal action. This is called 'Leave Behind' indicator in Flutter.

How do you create a rounded container in flutter?

In flutter, it is simple to create an easy rectangle and sq. form using container widget however they need sharp edges and therefore the corner is sharp however using the BoxDecoration property of box decoration we are able to simply and make the perimeters rounded. Container( decoration: BoxDecoration( border: Border.

How do I dismiss a widget in flutter?

A 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.


1 Answers

Try wrapping the dismissible widget under ClipRRect and add border radius to only CLipRRect and not the child widgets. That should fix your problem.

This question has already been discussed in: How to fix this dismissible widget border

like image 74
Rohith Nambiar Avatar answered Sep 23 '22 15:09

Rohith Nambiar