0

enter image description here

I have code like this

ClipRRect(
                              borderRadius:
                                  BorderRadius.all(Radius.circular(100.0)),
                              child: Image.network(
                                image_link_from_api,
                                width: 100,
                                height: 100,
                                fit: BoxFit.fill,
                              ),
                            ),

I tried ClipRRect, avatar image, container with rounded corners, nothing seems to work, so how can I fill whole round image instead of something like this in above image?

I tried fill, cover, contain, every possible option

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • Does this answer your question? [How to do Rounded Corners Image in Flutter](https://stackoverflow.com/questions/51513429/how-to-do-rounded-corners-image-in-flutter) – Ken White Feb 09 '23 at 02:07
  • 1
    Can you share the original image? Probably the image has a white background. Your code turns an image into a circle. To round the corners, change `Radius.circular(100.0)` to `Radius.circular(20.0)`. – yushulx Feb 09 '23 at 02:15
  • no, its like that on all images, does not matter if its longer in width or in height, if image is not perfectly square it shows like this https://i.ibb.co/37ZfCpQ/20230113213218image-thumbnail-media-433.jpg - here is the original image (sorry for low quality) – Sandro Basharuli Feb 09 '23 at 15:50
  • even when I try it with the ideal square it shows like this https://i.ibb.co/kQ74w8w/image.png – Sandro Basharuli Feb 09 '23 at 16:00
  • @SandroBasharuli I tried your code: https://i.stack.imgur.com/TSzRM.png – yushulx Feb 10 '23 at 05:23

1 Answers1

1

The effect of running your code:

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            ClipRRect(
              borderRadius: const BorderRadius.all(Radius.circular(100.0)),
              child: Image.network(
                'https://i.ibb.co/37ZfCpQ/20230113213218image-thumbnail-media-433.jpg',
                width: 100,
                height: 100,
                fit: BoxFit.fill,
              ),
            ),
          ],
        ),
      ),
    );
  }
}

enter image description here

yushulx
  • 11,695
  • 8
  • 37
  • 64