I have a problem with a dismissible border which is marked on the screenshot
https://imgur.com/a/Jv0sdi2
return Dismissible(
child: Container(
height: 256,
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(20.0)
)
)
);
);
Flutter Widget - Dismissible()Swiping list items left or right to dismiss them is a pretty common UI pattern. To make it work with Flutter, use the Dismissible widget. Dismissible takes a child, a background, and a key, and it will detect swipe gestures and animate the child, sliding over the background.
Steps to add border to container in Flutter:Step 1: Go to the Container in which you want to add a border. Step 2: Add the decoration parameter and assign the BoxDecoration class. Inside the BoxDecoration add the parameter border and set it to Border. all().
I've encountered the same problem when I was trying to have rounded corners.
Eventually a little workaround did the trick.
Instead of having a background
in the Dismissible
, create a Stack
and put the background widget behind the Dismissible
Stack(
overflow: Overflow.clip,
children: <Widget>[
MyBackgroundWidget(), // instead of background
Dismissible(
child: MyForegroundWidget(),
// no background
)
],
);
The problem is the clipping behavior in dismissible.dart. I've managed to solve the problem by editing the Dismissible class itself. In lines 559 - 573, you will find an if-statement that looks like this:
if (background != null) {
content = Stack(children: <Widget>[
if (!_moveAnimation.isDismissed)
Positioned.fill(
child: ClipRect(
clipper: _DismissibleClipper(
axis: _directionIsXAxis ? Axis.horizontal : Axis.vertical,
moveAnimation: _moveAnimation,
),
child: background,
),
),
content,
]);
}
If you just comment out the clipper-property in ClipRect, the background will be transparent and you won't lose the collapsing animation.
I found a solution. Wrap Dismissible widget with ClipRRect widget, and remove borderRadius from, child widgets. Only ClipRRect should have borderRadius.
ClipRRect(
borderRadius: BorderRadius.circular(15.0),
child: Dismissible(
child: YourWidgetContainer();
)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With