I want to put the image in the container so that it does not overflow the rounded edges of the container as seen on the screenshot.
This is my code:
FlipCard(
fill: Fill.fillBack,
direction: FlipDirection.HORIZONTAL,
speed: 400,
front: Container(
width: 200,
height: 200,
child: InteractiveViewer(
minScale: 0.1,
constrained: false,
panEnabled: false,
scaleEnabled: false,
transformationController: controller,
child: _tToImage(t),
),
decoration: BoxDecoration(
color: Config.BUTTON_CLR,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.all(Radius.circular(12)),
border: Border.all(
width: 1,
),
),
alignment: AlignmentDirectional(0, 0),
),
Use the ClipRRect.
ClipRRect(
borderRadius: BorderRadius.circular(12),
child: _tToImage(t)
),
Related
I have a Container in Flutter, which has 3 different Container with different colors as a child. The Main Container doesn't have rounded corners. Any ideas?
Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20.0)),
),
height: 8,
width: 300,
child: Row(children: [
Container(
decoration: BoxDecoration(color: Colors.lightGreen),
width: 300 * 0.37,
),
Container(
decoration: BoxDecoration(color: Colors.grey[300]),
width: 300 * 0.15,
),
Expanded(
child: Container(
decoration: BoxDecoration(color: Colors.redAccent),
),
),
]),
),
Wrap your outer container with ClipRRect and give it a border radius:
ClipRRect(
borderRadius: BorderRadius.circular(20),
child: Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20.0)),
),
height: 100,
width: 300,
child: Row(children: [
Container(
decoration: BoxDecoration(color: Colors.lightGreen),
width: 300 * 0.37,
),
Container(
decoration: BoxDecoration(color: Colors.grey[300]),
width: 300 * 0.15,
),
Expanded(
child: Container(
decoration: BoxDecoration(color: Colors.redAccent),
),
),
]),
),
),
You can give different border and color for each container like that
Container(child : Widget(),
decoration: BoxDecoration(
border: Border.all(
color: Colors.anyColor,
),
borderRadius: BorderRadius.all(Radius.circular(anyValue))
))
I generated dynamic color from images and make it background color.
I want soft edges of background image and color. How do I implement it?
Container(
decoration: BoxDecoration(
color: Colors.blueAccent,
border: Border.all(
width: 0.5,
),
borderRadius: BorderRadius.all(
Radius.circular(24),
),
),
child: Stack(
children: [
Positioned.fill(child: ProductImageWidget()),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: ProductNameWidget(),
)
],
),
);
Use ClipRRect
ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Image.network(
"src",
height: 150.0,
width: 100.0,
),
)
wrap your ProductImageWidget() with ClipRReact. Where there is a property called borderRadius.
ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: ProductImageWidget(),
)
Or you can use this widget in the inner code of ProductImageWidget() as a parent widget
You will need a ClipRRect and a BackDropFilter to get the effect that you want. By the way this effect is called frosted glass, you can find many info about it. Let me show you an example (I not tested it :) ).
ClipRRect(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3),
child: Container(
decoration: BoxDecoration(
color: Colors.blueAccent,
border: Border.all(
width: 0.5,
),
borderRadius: BorderRadius.all(
Radius.circular(24),
),
),
child: Stack(
children: [
Positioned.fill(child: ProductImageWidget()),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: ProductNameWidget(),
)
],
),
);
),
),
I am trying to make the display feature for my app, but I am having a hard time making these outer circles, any input is appreciated
There is a way to draw using coordinates.
You can set the ratio using MediaQuery.of(context).size.
return Scaffold(
body: SafeArea(
child: Stack(
children: <Widget>[
Positioned(
top: 200,
left: 80,
child: Container(
width: 200,
height: 200,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(128.0),
border: Border.all(color: Colors.blue),
),
),
),
Positioned(
top: 225,
left: 105,
child: Container(
width: 150,
height: 150,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(128.0),
border: Border.all(color: Colors.blue),
),
),
),
],
),
),
);
Use this:
Container(
color: Colors.white,
child: Center(
child: Container(
width: 200,
height: 200,
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: [Colors.white,Colors.white, Colors.red, Colors.red, Colors.white,Colors.white],
transform: GradientRotation(pi / 2),
),
borderRadius: BorderRadius.circular(128.0),
),
child: Center(
child: Container(
width: 198,
height: 198,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(120.0),
),
),
),
),
),
),
It leads to this output:
use stack widget and put 2 circle containers with different size as children in stack widget
How can I make a shape (or any widget for that matter) overlap the sides of the phone-screen?
I've attached an image that showes what I mean.
Here's my code so far:
Container(
width: 900.0,
height: 900.0,
decoration: new BoxDecoration(
color: Colors.orange,
shape: BoxShape.circle,
),
),
And no, I it doesn't help to increse the size to say 1000, it just stays the same
I just modified the answer.
Transform.scale(
scale: 1.4,
child: Center(
child: Container(
width: 900.0,
height: 900.0,
decoration: new BoxDecoration(
color: Colors.orange,
shape: BoxShape.circle,
),
),
),
)
Add a Transform widget with a proper scale property and remove the height and width in the Container.
Transform.scale(
scale: 1.7,
child: Container(
decoration: new BoxDecoration(
color: Colors.orange,
shape: BoxShape.circle,
),
),
)
I'm using 'polygon_clipper 1.0.2' to clip my container.
Container(
height: 100,
width: 100,
child: ClipPolygon(
child: Container(
color: Theme.of(context).primaryColor,
),
sides: 6,
borderRadius: 10,
),
),
Here I get a Filled Hexagon, whose vertexes are curved.
I want a hexagon with just the border.
The following code gives a container having a rounded border.
I want similar result but sides should be 6.
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border: Border.all(
width: 2, color: Theme.of(context).primaryColor
),
),
height: 100,
width: 100,
)
Any Solution ?
You can use PolygonBorder:
import 'package:polygon_clipper/polygon_border.dart';
Container(
height: 100,
width: 100,
decoration: ShapeDecoration(
shape: PolygonBorder(
sides: 6,
borderRadius: 10,
border: BorderSide(
color: Theme.of(context).primaryColor,
)
),
)
),