Skip to content
Readerstacks logo Readerstacks
  • Home
  • Softwares
  • Angular
  • Php
  • Laravel
  • Flutter
Readerstacks logo
Readerstacks
How to add rounded border radius to image in flutter

How to add rounded border radius to image in flutter ?

Aman Jain, September 19, 2022March 16, 2024

In this article we will learn to add rounded border radius to image in flutter. In flutter rounded corner border can be added using borderRadius but to add the rounded border to image is not same because by adding the border radius to container it won’t apply to child image.

In this article i will show you multiple methods to add rounded corner to image. We will use background image to add border radius, ClipRRect, ClipOval and CircleAvatar. In this example i will create a simple image with border radius, width and color of border as well.

Flutter use BoxDecoration class to render the border and borderRadius in container widget it accepts multiple options like border, border radius, color, background image, gradient, shape and etc. so to add the borderRadius first we need to add decoration option to container and then in decoration value we need to assign BoxDecoration class to implement the border.

Let’s implement the methods to add rounded border radius to image in flutter

Method 1 : Using backgroundImage to add rounded border to image

In this method we will use the backgroundImage attribute BoxDecoration to add the rounded border to image

Container(
            margin: const EdgeInsets.only(top: 20),
            height: 100,
            width: 100,
            decoration:  BoxDecoration(
            border: Border.all(color: Colors.red,width: 10),
              borderRadius: BorderRadius.circular(50.0),
             image: const DecorationImage(
                 fit: BoxFit.cover,
                 image: NetworkImage('https://picsum.photos/id/238/200')
            ),
            ),
),
rounder image in flutter
rounder image in flutter

Method 2 : Using ClipRRect to add rounded border to image

In this method we will use the ClipRRect to add the rounded border to image

 Container(
            decoration:  BoxDecoration(
              borderRadius: BorderRadius.circular(105.0),
              border: Border.all(color: Colors.red,width: 10)
            ),
            child: ClipRRect(
              borderRadius: BorderRadius.circular(100),
              child:Image.network("https://picsum.photos/200" ),
            ),
          ),
rounded border image in flutter
rounded border image using ClipRRect in flutter

Method 3 : Using CircleAvatar to add rounded border to image

In this method we will use the CircleAvatar to add the rounded border to image

Container(
            margin: const EdgeInsets.only(top: 20),
            height: 100,
            width: 100,
            decoration:  BoxDecoration(
              border: Border.all(color: Colors.red,width: 10),
              borderRadius: BorderRadius.circular(50.0),

            ),
            child: const CircleAvatar(
              backgroundColor: Colors.red,
              backgroundImage: NetworkImage('https://picsum.photos/id/237/200'),
              radius: 50,

            ),
          ),
rounded image with border color and width in flutter
rounded image with border color and width in flutter

One side border radius to widget flutter

Sometimes we also want to add border radius to specific one side of widget or container so then we can use BorderRadius.only class named constructor to add the border radius to the one side or any side of container as follow

Container(
  padding: EdgeInsets.all(10),
  decoration: BoxDecoration(
      border: Border.all(color: Colors.white),
      borderRadius: const BorderRadius.only(
          bottomLeft: Radius.circular(20.0),
          topRight: Radius.circular(20.0))),
  child: const Text(
    'Hello, World!',
    style: TextStyle(color: Colors.white, fontSize: 30),
  ),
),
one side rounded corner in flutter using border radius
one side rounded corner in flutter using border radius

Let’s understand it with example

Step 1 : Create flutter project

Very first step is to create the fluter application using command line tool or in Android studio.

flutter create example_app

This will create a new project with name my_app then go in to the folder .

Step 2 : Create a simple widget

Now, Create a simple state less widget to add a border with image in flutter as follow

File : lib/borderimage.dart

class RoundedImage extends StatelessWidget {
  const RoundedImage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.only(top: 40),
      color: Colors.white,

      child: Column(
        children: [
          Container(
            decoration:  BoxDecoration(
              borderRadius: BorderRadius.circular(105.0),
              border: Border.all(color: Colors.red,width: 10)
            ),
            child: ClipRRect(
              borderRadius: BorderRadius.circular(100),
              child:Image.network("https://picsum.photos/200" ),
            ),
          ),
          Container(
            margin: const EdgeInsets.only(top: 20),
            height: 100,
            width: 100,
            decoration:  BoxDecoration(
            border: Border.all(color: Colors.red,width: 10),
              borderRadius: BorderRadius.circular(50.0),
             image: const DecorationImage(
                 fit: BoxFit.cover,
                 image: NetworkImage('https://picsum.photos/id/238/200')
            ),
            ),
          ),
          Container(
            margin: const EdgeInsets.only(top: 20),
            height: 100,
            width: 100,
            decoration:  BoxDecoration(
              border: Border.all(color: Colors.red,width: 10),
              borderRadius: BorderRadius.circular(50.0),

            ),
            child: const CircleAvatar(
              backgroundColor: Colors.red,
              backgroundImage: NetworkImage('https://picsum.photos/id/237/200'),
              radius: 50,

            ),
          ),

        ],
      ),
    );
  }
}

Step 3: Import and use the widget in main

We just created a new widget with name RoundedImage, now we are going to use it in our main.dart file as below

import 'package:flutter/material.dart'; 
import 'package:example_app/borderimage.dart';;

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(
        scaffoldBackgroundColor: darkBlue,
      ),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: RoundedImage(),
        ),
      ),
    );
  }
}

Step 4: Run the project

Simply run the project using command line or in android studio to check the implementation.

flutter run lib/main.dart

Read Also : How to add border to container or any widget flutter?

Related

Dart Flutter borderborderRadiusFluttterimagerounded

Post navigation

Previous post
Next post

Related Posts

Dart Display Asset Image in Flutter

How to show local(asset) image in flutter application?

January 2, 2022January 15, 2022

In this tutorial we will learn to show assets image in flutter. In flutter there is two types of images we can show one is asset image and other one is network image. To use the images in flutter we have Image class which supports both local and remote images….

Read More
Flutter Display background image in Flutter

How to display background image in flutter ?

January 15, 2022August 29, 2022

In our recent article i showed you to display local or remote image in flutter application but in some cases we need to show our image in background so we can put additional content on it. Background image is useful to show when we wanted to show full image in…

Read More
Flutter Create a bottom tab in flutter

How to create bottom tab bar in flutter ?

January 9, 2022January 15, 2022

In this tutorial i will show you to create bottom tab in flutter. Now days bottom tabbing is much popular then creating drawer because tabbing is much easy to user and you can easily switch between the tabs. I will show you in this article to change the color of…

Read More

Aman Jain
Aman Jain

With years of hands-on experience in the realm of web and mobile development, they have honed their skills in various technologies, including Laravel, PHP CodeIgniter, mobile app development, web app development, Flutter, React, JavaScript, Angular, Devops and so much more. Their proficiency extends to building robust REST APIs, AWS Code scaling, and optimization, ensuring that your applications run seamlessly on the cloud.

Categories

  • Angular
  • CSS
  • Dart
  • Devops
  • Flutter
  • HTML
  • Javascript
  • jQuery
  • Laravel
  • Laravel 10
  • Laravel 11
  • Laravel 9
  • Mysql
  • Php
  • Softwares
  • Ubuntu
  • Uncategorized

Archives

  • June 2025
  • May 2025
  • April 2025
  • October 2024
  • July 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • July 2023
  • March 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Recent Posts

  • The Resilience of Nature: How Forests Recover After Fires
  • Understanding Laravel Cookie Consent for GDPR Compliance
  • Understanding High Vulnerabilities: A Critical Overview of the Week of May 12, 2025
  • Installing a LAMP Stack on Ubuntu: A Comprehensive Guide
  • Understanding High Vulnerabilities: A Deep Dive into Recent Security Concerns
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version