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

跟風遠走 提交于 2019-12-11 19:47:29

问题


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.


回答1:


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:



来源:https://stackoverflow.com/questions/54087139/how-can-i-add-2-tone-icons-without-using-any-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!