Skip to content

Instantly share code, notes, and snippets.

@sgruhier
Created May 25, 2024 09:31
Show Gist options
  • Save sgruhier/9deec0df9db9f76a6016cb058698e687 to your computer and use it in GitHub Desktop.
Save sgruhier/9deec0df9db9f76a6016cb058698e687 to your computer and use it in GitHub Desktop.
Built in animation
return Scaffold(
body: Center(
child: AnimatedContainer(
duration: const Duration(seconds: 1),
width: _toggled ? 200 : 100,
height: _toggled ? 200 : 100,
decoration: BoxDecoration(
color: _toggled ? Colors.blue : Colors.red,
borderRadius: BorderRadius.circular(_toggled ? 20 : 0),
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
_toggled = !_toggled;
});
},
child: const Icon(Icons.play_arrow),
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment