How to add shadow to the text in flutter?

ZeroProcess picture ZeroProcess · Jun 1, 2017 · Viewed 28k times · Source

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(
"asd"
style: new TextStyle( 
//add shadow?
));

Answer

Gary Qian picture Gary Qian · Oct 17, 2018

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<Shadow> to TextStyle.shadows:

import 'dart:ui';

...

Text(
  'Hello, world!',
  style: TextStyle(
    shadows: <Shadow>[
      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.