Lets animate Text as well!

For animating text we have to use AnimatedDefaultTextStyle instead of Text Widget. 
For providing much better experience we will change the Fontweight and Color of the text. And lets also change color of Container to get better animating effect. 

So your code should look like this :

bool bigger = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            setState(() {
              bigger = !bigger;
            });
          },
          child: Icon(Icons.refresh),
        ),
        body: Center(
          child: AnimatedContainer(
            duration: Duration(seconds: 1),
            width: bigger ? 600 : 450,
            height: bigger ? 400 : 300,
            color: bigger ? Colors.black : Colors.orange,
            child: Center(
              child: AnimatedDefaultTextStyle(
                duration: Duration(seconds: 1),
                child: Text("Implicit Animating Widgets"),
                textAlign: TextAlign.center,
                style: TextStyle(
                    fontSize: 30,
                    color: bigger ? Colors.orange : Colors.black,
                    fontWeight: bigger ? FontWeight.bold : FontWeight.normal),
              ),
            ),
          ),
        ));
  }
Discussion

4

0