How to add shadow to the text in flutter?

后端 未结 4 1957
鱼传尺愫
鱼传尺愫 2021-01-30 21:47

I searched for the shadow option in TextStyle, but I didn\'t find it. So I ask: how can I add shadow to the text in flutter? Is it possible? Example:

new Text(
\         


        
4条回答
  •  野性不改
    2021-01-30 22:34

    Text shadows are now a property of TextStyle as of this commit

    To enable text shadows, please make sure you are on an up-to-date version of Flutter ($ flutter upgrade) and provide a List to TextStyle.shadows:

    import 'dart:ui';
    
    ...
    
    Text(
      'Hello, world!',
      style: TextStyle(
        shadows: [
          Shadow(
            offset: Offset(10.0, 10.0),
            blurRadius: 3.0,
            color: Color.fromARGB(255, 0, 0, 0),
          ),
          Shadow(
            offset: Offset(10.0, 10.0),
            blurRadius: 8.0,
            color: Color.fromARGB(125, 0, 0, 255),
          ),
        ],
      ),
    ),
    
    ...
    

    Keep in mind that shadows will be drawn in the order provided.

提交回复
热议问题