简体   繁体   English

如何在 Flutter 中用图像屏蔽文本?

[英]How can I mask a text with image in Flutter?

Hello does anyone know how i can mask a text and photo in flutter?你好有谁知道我如何在颤振中屏蔽文本和照片? I already have my image with text on the screen.我已经在屏幕上显示了带有文本的图像。 For example: my text would be Lion and my photo of these lions are behind it.例如:我的文字是狮子,我的这些狮子的照片在它后面。 How can i make a mask like you can in photoshop?我怎样才能像在photoshop中那样制作面具?

See this photo for example:例如,请参阅这张照片: 文字和照片蒙版

I'm not sure this answers your question.我不确定这能回答你的问题。 It's a simple version of text masking but instead of masking an image this MIN REPRO EXAMPLE shows masking gradient colors:这是文本遮罩的简单版本,但不是遮罩图像,此 MIN REPRO 示例显示遮罩渐变颜色:

 ShaderMask(
                        shaderCallback: (bounds) => RadialGradient(
                          colors: [
                            Colors.red,
                            Colors.green,
                          ],
                        ).createShader(bounds),
                        child: const Text('exclusive'),
                      ),

Unfortunately, as of writing ShaderMask is not supported yet for web online for iOS/Android.不幸的是,截至撰写ShaderMask ,iOS/Android 的网络在线尚不支持ShaderMask Check out more here: https://github.com/flutter/flutter/issues/44152在此处查看更多信息: https : //github.com/flutter/flutter/issues/44152

You may find these answers useful (just again they may not be supported on web yet I don't know about other solutions):您可能会发现这些答案很有用(同样,网络上可能不支持它们,但我不知道其他解决方案):

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM