Rounded Corner Image in Flutter
Last Updated :
28 Apr, 2025
Rounded images or avatars are commonly used in many mobile applications, including those built with Flutter. There are several ways to create rounded images in Flutter, some of which include:
- Using the ClipRRect widget: As I mentioned earlier, the ClipRRect widget can be used to clip an image and create rounded corners.
- Using the Container widget with BoxDecoration: You can use the Container widget to create a container for your image, and then use BoxDecoration to set the shape property to BoxShape.circle to create a circular avatar.
- Using a CustomPainter: This is a more advanced method, but it allows you to create a custom shape for your avatar.
- Using the CircleAvatar widget: This widget is specifically designed to create circular avatars. It takes an Image or Icon as a child and automatically clips it into a circle.
- Using ClipOval: This is another way to clip an image into a circular shape, similar to CircleAvatar
Step By Step Implementation
Step 1: Create a New Project in Android Studio
To set up Flutter Development on Android Studio please refer to Android Studio Setup for Flutter Development, and then create a new project in Android Studio please refer to Creating a Simple Application in Flutter.
Step 2: Import the Material Package
A material package gives us the essential functions and Parameters, Now call the runApp method that needs an Application in the main function.
import 'package:flutter/material.dart';
void main() {
runApp(RunMyApp());
}
In the above code, runApp method calls the class RunMyApp, Now we have to create it.
Step 3: Creating Stateless Widget
Now we have to make a stateless widget because our application does not go to change its state and then return the MaterialApp widget which allows us the set the title and theme and many more of the application.
Shortcut for creating a stateless or Stateful widget: You can create a stateless widget by just typing three alphabets ‘stl’ and you can see a stateless widget and then hit enter.
class RunMyApp extends StatelessWidget {
const RunMyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp();
}
}
Step 4: Working with Scaffold Widget
Give the home property and there can be a scaffold widget with AppBar and body property. AppBar allows us to give the title of AppBar, color, leading, and trailing icon.
home: Scaffold(
appBar: AppBar(
title: Text('Grid Paper'),
),
body:
),
Step 5: Making a Rounded Image
Now we can simply use the following widgets and assign its parameter to make the image rounded.
1. Circular Image (without border)
Using CircleAvatar:
Dart
CircleAvatar(
radius: 48, // Image radius
backgroundImage: AssetImage('assets/gfglogo.png'),
),
Using ClipRRect:
Dart
ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(48), // Image radius
child: Image.asset('assets/gfglogo.png', fit: BoxFit.cover),
),
),
Output: Same for Both the Methods
2. Circular Image (with border)
Using CircleAvatar:
Dart
CircleAvatar(
radius: 56, //radius of avatar
backgroundColor: Colors.green, //color
child: Padding(
padding: const EdgeInsets.all(8), // Border radius
child: ClipOval(child: Image.asset('assets/gfglogo.png')),
),
)
Using ClipRRect:
Dart
Container(
padding: EdgeInsets.all(8), // Border width
decoration: BoxDecoration(color: Colors.green, shape: BoxShape.circle),
child: ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(48), // Image radius
child: Image.asset('assets/gfglogo.png', fit: BoxFit.cover),
),
),
)
Output: Same for Both the Method
Similar Reads
Flutter - Convert an Image into Base64 String Base64 encoding is used to convert bytes that have binary or text data into ASCII characters. Encoding prevents the data from getting corrupted when it is transferred or processed through a text-only system. In this article, we will discuss how to convert an image into Base64 String. A sample video
4 min read
Flutter - Animate Image Rotation In Flutter, Image.assets() or Image.network() Widget is used to display images from locally or from a URL. Images can be locally stored in the program or fetched from a network and can be displayed using the Image Widget. Animations can be applied to Images via many techniques. Hence, in this articl
4 min read
How to Create a Zoomable Image in Flutter? In Flutter, you can create a zoomable image using the GestureDetector and Transform widgets. The GestureDetector widget can be used to detect pinch gestures on the image, and the Transform widget can be used to apply the zoom transformation to the image. How to Use:Container( child: PhotoView( image
3 min read
Flutter - Set Background Image In this article, we are going to implement how to set the background image in the body of the scaffold. A sample image is given below to get an idea about what we are going to do in this article. Step By Step ImplementationStep 1: Create a New Project in Android StudioTo set up Flutter Development o
3 min read
Display Network Image in Flutter Flutter has an Image widget to display different types of images. To display images from the internet, the Image.network()function is used.Syntax:Image.network ('source_URL')Constructor of Image.network:Image Image.network( String src, { Key? key, double scale = 1.0, Widget Function(BuildContext, Wi
3 min read
Flutter - Upload Images on FireStore Storage Firestore is a free platform that provides users or developers to test their apps without any cost. However, you have to pay a small amount of money with which you hosted your app and earn money through their services. Firebase or Firestore provides a variety of services: Firestore DatabaseAnalytics
4 min read