Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add 2 tone icons without using any plugin?

I don't want to add any plugins just for one icon in my app but I need two tone because the background color will vary and I don't know when it will be dark and when it will be light.

I mean icons like these - https://material.io/tools/icons/?style=twotone where icons have border of different color.

like image 372
Keerti Purswani Avatar asked Sep 14 '25 20:09

Keerti Purswani


1 Answers

If i understood your Question Correctly, here is an example of two Color Tone Icon & Text.

You can play around with Color, radius & other Parameters to fit your Needs.

body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            ShaderMask(
              blendMode: BlendMode.srcATop,
              shaderCallback: (Rect bounds) {
                return RadialGradient(
                  center: Alignment.topLeft,
                  radius: 1.0,
                  colors: <Color>[Colors.red, Colors.cyanAccent],
                  tileMode: TileMode.mirror,
                ).createShader(bounds);
              },
              child: Text(
                'Two Tone Color Icon & Text!',
                style: TextStyle(fontSize: 22.0),
              ),
            ),
            SizedBox(
              height: 10.0,
            ),
            ShaderMask(
              blendMode: BlendMode.srcATop,
              shaderCallback: (Rect bounds) {
                return RadialGradient(
                  center: Alignment.center,
                  radius: 1.0,
                  colors: <Color>[
                    Colors.greenAccent[200],
                    Colors.blueAccent[200]
                  ],
                  tileMode: TileMode.repeated,
                ).createShader(bounds);
              },
              child: Icon(
                Icons.dashboard,
                size: 32.0,
              ),
            ),
          ],
        ),
      ),

Output: enter image description here

like image 150
anmol.majhail Avatar answered Sep 17 '25 10:09

anmol.majhail