How to achieve animated textStyle shadow in Flutter

0

I'm trying to animate the textsyle of an AnimatedDefaultTextStyle widget so that the result would have the text's shadow 'grow' for an effect of gradual elevation. Currently when the state that controls the preferred textstyle changes it just jumps between states without animating.

Here's the code for the widget;

    AnimatedDefaultTextStyle(
                    duration: Duration(milliseconds: 700),
                    style: switchWord
                        ? TextStyle(
                            fontSize: 70.0,
                            fontWeight: FontWeight.w700,
                            color: Color(0xFFE0E5EC),
                            shadows: [
                              Shadow(
                                color: Colors.transparent,
                                blurRadius: 0.0,
                                offset: Offset(0.0, 0.0),
                              ),
                              Shadow(
                                color: Colors.transparent,
                                blurRadius: 0.0,
                                offset: Offset(0.0, 0.0),
                              ),
                            ],
                          )
                        : TextStyle(
                            fontSize: 70.0,
                            fontWeight: FontWeight.w700,
                            color: Color(0xFFE0E5EC),
                            shadows: [
                              Shadow(
                                color: Color(0xFFFFFFFF).withOpacity(0.5),
                                blurRadius: 5.0,
                                offset: Offset(-2.0, -5.0),
                              ),
                              Shadow(
                                color: Color(0xFFA3B1C6).withOpacity(0.5),
                                blurRadius: 5.0,
                                offset: Offset(2.0, 5.0),
                              ),
                            ],
                          ),
                    child: Text('${textList[currentText]}'),
                  ),

I call setState(() => switchWord = !switchWord); whenever a button is pressed.

animation
flutter
shadow
textstyle
asked on Stack Overflow Dec 28, 2019 by Dee

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0