animated_svg 1.0.0 animated_svg: ^1.0.0 copied to clipboard
Flutter package for displaying and animating Scalable Vector Graphics 1.1 files.
Example #
Media Player - an example of basic implementation of AnimatedSvg
. Simple project that simulates a media player. As usual, the player needs play and pause buttons. Thanks to the AnimatedSvg
package, it is so easy to create a smooth transition between play and pause SVGs.
main.dart
// Define an SvgController
late final SvgController _controller;
@override
void initState() {
// Initialize SvgController
_controller = AnimatedSvgController();
super.initState();
}
@override
void dispose() {
// Dispose SvgController
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
// Call the AnimatedSvg widget anywhere in your widget tree.
return AnimatedSvg(
controller: _controller,
duration: const Duration(milliseconds: 600),
onTap: () {},
size: 80,
clockwise: false,
isActive: true,
children: [
SvgPicture.asset(
'assets/play.svg',
height: 40,
width: 40,
),
SvgPicture.asset(
'assets/pause.svg',
height: 40,
width: 40,
),
],
);
}