Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Flutter Web Icon doesn't fit inside Container

I have tried removing all padding and border and put the icon inside a FittedBox but the are still parts of the Container that are visible. How can I remove them? Thank you in advance.

Orange Icon above a blue Container

void main() => runApp(const MyApp());
 
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
 
  @override
  Widget build(BuildContext context) {
    return CupertinoApp(
      title: 'Cupertino App',
      debugShowCheckedModeBanner: false,
      home: CupertinoPageScaffold(
        child: Center(
          child: CupertinoButton(
            minSize: 15,
            padding: EdgeInsets.zero,
            onPressed: () {},
            child: Container(
              width: 40,
              padding: EdgeInsets.zero,
              decoration: BoxDecoration(
                shape: BoxShape.circle,
                color: Colors.blue,
                border: Border.all(
                  width: 0,
                  color: Colors.transparent,
                ),
              ),
              child: const FittedBox(
                fit: BoxFit.cover,
                child: Icon(
                  CupertinoIcons.minus_circle_fill,
                  color: Colors.amber,
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The container colors are visible because the Icon assets comes with default padding, You can check this question: How to get rid of a icon padding,

You can use transparent Color on the Container to hide it.

decoration: BoxDecoration(
  shape: BoxShape.circle,
  color: Colors.transparent, // here
  border: Border.all(
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading