[Flutter/dart] Display the image with rounded corners
Overview
When displaying an image in the app, you may want to round the corners of the original image.
So, this time, I will introduce such a method.
Method
First of all, it will be like this when displayed as it is.
Widget _myImg(){
return Image.asset('image/sample.jpg',);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: SingleChildScrollView(
child: Center(
child: Container(
padding: const EdgeInsets.all(32),
child: _myImg(),
width: double.infinity,
),
)
),
);
}
Use ClipRRect to round the corners.
Widget _myImg(){
return ClipRRect(
child: Image.asset('image/sample.jpg',),
borderRadius: BorderRadius.all(Radius.circular(10)),
);
}
Recent Posts
See AllWhat want to do I want to create an input form using TextField. For example, if the input content is a monetary amount, I would like to...
What want to do There is a variable that remain unchanged once the initial value is determined. However, it cannot be determined yet when...
What want to do As the title suggests. Place two widgets in one line on the screen One in the center of the screen and the other on the...
Comments