Flutter – Round Image

Round Image in Flutter

To display a Round Image in Flutter, you can use Container with BoxDecoration, and use BoxShape.circle for shape and provide the image for image property.

Sample Code Snippet

Following is a quick code snippet that outlines the widgets and property values to display a image in the shape of a circle.

Container(
  width: 200,
  height: 200,
  decoration: BoxDecoration(
	shape: BoxShape.circle,
	image: DecorationImage(
	  image: NetworkImage('https://googleflutter.com/sample_image.jpg'),
	  fit: BoxFit.fill
	),
  ),
),

In this tutorial, we have loaded image over network. You can also, load an image from assets.

Example

In this example, we will create a Flutter Application to display an image as a circular disc in UI.

To recreate this application, create a basic Flutter Application and replace main.dart with the following code.

main.dart

import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: MyApp(),
  ));
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: new Text("Flutter Tutorial - googleflutter.com"),
      ),
      body: Center(
          child: Column(children: <Widget>[
        Container(
          margin: EdgeInsets.all(20),
          width: 200,
          height: 200,
          decoration: BoxDecoration(
            shape: BoxShape.circle,
            image: DecorationImage(
              image: NetworkImage('https://googleflutter.com/sample_image.jpg'),
              fit: BoxFit.fill
            ),
          ),
        ),
      ])),
    );
  }
}

Screenshot

Run the application on an emulator or device, and you should see an UI as shown below.

flutter round image

Summary

In this Flutter Tutorial, we displayed an image in round or circle shape.

Desclaimer: We are not affiliated, associated, authorized, endorsed by, or in any way officially connected with the Google, Apple or Flutter, or any of its subsidiaries or its affiliates. The names Google, Apple and Flutter as well as related names, marks, emblems and images are registered trademarks of their respective owners. This site googleflutter.com covers tutorials related to Flutter developed by Google.