drawing_animation examples

drawing_animation is a Dart package that can gradually paint SVG path objects on a canvas.

In this example, we will try to animate the drawing of the potion below.

Add the dependency to pubspec.yaml before using the code below.

drawing_animation: ^0.1.4

import 'package:flutter/material.dart';
import 'package:drawing_animation/drawing_animation.dart';

class DrawingAnimationPage extends StatefulWidget {
  @override
  _DrawingAnimationPageState createState() => _DrawingAnimationPageState();
}

class _DrawingAnimationPageState extends State<DrawingAnimationPage> {
  bool _run = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Draw a Potion SVG'),
      ),
      body: Center(
        child: AnimatedDrawing.svg(
          "assets/potion.svg",
          run: _run,
          duration: new Duration(seconds: 3),
          onFinish: () => setState(() {
            _run = false;
          }),
        ),
      ),
    );
  }
}

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.

Close