Flutter AnimatedPhysicalModel Example

PhysicalModel properties can be animated with its animated widget version, AnimatedPhysicalModel. The widget can animate borderRadius, elevation, and color (if the Color property is set).

This post will introduce an AnimatedPhysicalModel example of animating all values which are possible to be animated.

import 'package:flutter/material.dart';

class Homepage extends StatefulWidget {
  const Homepage({Key? key}) : super(key: key);

  _HomepageState createState() => _HomepageState();

class _HomepageState extends State<Homepage> {
  bool _play = false;

  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: AnimatedPhysicalModel(
          duration: Duration(seconds: 1),
          color: _play ? Colors.red : Colors.blue,
          elevation: _play ? 9 : 3,
          shape: BoxShape.rectangle,
          shadowColor: Colors.deepOrangeAccent,
          borderRadius: _play
              ? const BorderRadius.all(Radius.circular(0))
              : const BorderRadius.all(Radius.circular(24)),
          child: Container(
            width: 240,
            height: 240,
            child: Center(
                child: Text(
              style: TextStyle(fontSize: 18.0, color: Colors.white),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            _play = !_play;
        child: Icon(Icons.play_arrow),

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.