Git Product home page Git Product logo

biocarl / drawing_animation Goto Github PK

View Code? Open in Web Editor NEW
479.0 14.0 116.0 353 KB

A Flutter library for gradually painting SVG path objects on canvas (drawing line animation).

Home Page: https://pub.dartlang.org/packages/drawing_animation

License: BSD 2-Clause "Simplified" License

Java 0.19% Objective-C 0.05% Dart 32.87% Ruby 2.12% Shell 0.44% Kotlin 0.17% Swift 1.67% CMake 21.73% C++ 33.71% C 1.96% HTML 5.09%
flutter dart svg svg-animations svg-path

drawing_animation's Introduction

Welcome to my side ๐Ÿ‘‹

  • #f03c15 I love Clojure
  • #1589F0 and testing out the new Markdown profile feature.
- Just playing around with different colors
+ like green
! ... and orange
# gray 
@@ and some purple thingy. @@

drawing_animation's People

Contributors

abbasghomi avatar biocarl avatar fasihferoze avatar mgallo avatar musaddiq625 avatar nana-kwame-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

drawing_animation's Issues

Build getting failed with Flutter version 2.10.2

``

lib\main.dart:1
/C:/Users/user/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/drawing_animation-1.0.1/lib/src/abstract_drawing_state.dart:68:31: Error: Method 'addPostFrameCallback' cannot be called on 'SchedulerBinding?' because it is potentially null.

  • 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('/C:/Users/user/Documents/flutter/packages/flutter/lib/src/scheduler/binding.dart').
    package:flutter/โ€ฆ/scheduler/binding.dart:1
    Try calling using ?. instead.
    SchedulerBinding.instance.addPostFrameCallback((_) {
    ^^^^^^^^^^^^^^^^^^^^
    /C:/Users/user/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/drawing_animation-1.0.1/lib/src/drawing_state.dart:12:35: Error: Method 'addPostFrameCallback' cannot be called on 'SchedulerBinding?' because it is potentially null.

  • 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('/C:/Users/user/Documents/flutter/packages/flutter/lib/src/scheduler/binding.dart').
    package:flutter/โ€ฆ/scheduler/binding.dart:1
    Try calling using ?. instead.
    SchedulerBinding.instance.addPostFrameCallback((_) {

                                ^^^^^^^^^^^^^^^^^^^^
    

/C:/Users/user/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/drawing_animation-1.0.1/lib/src/drawing_state_with_ticker.dart:14:35: Error: Method 'addPostFrameCallback' cannot be called on 'SchedulerBinding?' because it is potentially null.

  • 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('/C:/Users/user/Documents/flutter/packages/flutter/lib/src/scheduler/binding.dart').
    package:flutter/โ€ฆ/scheduler/binding.dart:1
    Try calling using ?. instead.
    SchedulerBinding.instance.addPostFrameCallback((_) {

Implement complete SVG parsing

I'm currently considering to add flutter_svg as dependency for more complete SVG parsing.

that would be awesome if you implement it.

Originally posted by @laxxxguy in #4 (comment)

Update needed!

Please update this package, unable to add latest generated projects

NoSuchMethodError: The getter 'isNotEmpty' was called on null

Hi I'm trying to run example apps (in this case example_01) and following error occurs:

flutter: โ•โ•โ•ก EXCEPTION CAUGHT BY WIDGETS LIBRARY โ•žโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
flutter: The following NoSuchMethodError was thrown building AnimatedDrawing(dirty, state:
flutter: _AnimatedDrawingWithTickerState#93952(ticker active)):
flutter: The getter 'isNotEmpty' was called on null.
flutter: Receiver: null
flutter: Tried calling: isNotEmpty
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0      Object.noSuchMethod (dart:core/runtime/lib/object_patch.dart:50:5)
flutter: #1      _AbstractAnimatedDrawingState.getPathPainter 
package:drawing_animation/src/drawing_widget.dart:387
flutter: #2      _AbstractAnimatedDrawingState.getCustomPaint 
package:drawing_animation/src/drawing_widget.dart:427
flutter: #3      _AnimatedDrawingWithTickerState.build 
package:drawing_animation/src/drawing_widget.dart:562
flutter: #4      StatefulElement.build 
package:flutter/โ€ฆ/widgets/framework.dart:3830
flutter: #5      ComponentElement.performRebuild 
package:flutter/โ€ฆ/widgets/framework.dart:3741
flutter: #6      Element.rebuild 
package:flutter/โ€ฆ/widgets/framework.dart:3564
flutter: #7      ComponentElement._firstBuild 

This is my flutter doctor output (censored a bit)

[โœ“] Flutter (Channel beta, v1.3.8, on Mac OS X 10.14.3 18D109, locale pl-PL)
    โ€ข Flutter version 1.3.8 at /Users/.../Library/flutter
    โ€ข Framework revision e5b1ed7a7f (3 weeks ago), 2019-03-06 14:23:37 -0800
    โ€ข Engine revision f4951df193
    โ€ข Dart version 2.2.1 (build 2.2.1-dev.0.0 571ea80e11)

[โœ“] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    โ€ข Android SDK at ...
    โ€ข Android NDK location not configured (optional; useful for native profiling support)
    โ€ข Platform android-28, build-tools 28.0.3
    โ€ข Java binary at: ...
    โ€ข Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    โ€ข All Android licenses accepted.

[โœ“] iOS toolchain - develop for iOS devices (Xcode 10.1)
    โ€ข Xcode at /Applications/Xcode.app/Contents/Developer
    โ€ข Xcode 10.1, Build version 10B61
    โ€ข ios-deploy 1.9.4
    โ€ข CocoaPods version 1.5.3

[โœ“] Android Studio (version 3.3)
    โ€ข Android Studio at ...
    โ€ข Flutter plugin version 33.1.1
    โ€ข Dart plugin version 182.5215
    โ€ข Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[โœ“] VS Code (version 1.32.3)
    โ€ข VS Code at /Applications/Visual Studio Code.app/Contents
    โ€ข Flutter extension version 2.24.0

[โœ“] Connected device (1 available)
    โ€ข iPhone XS โ€ข ... โ€ข ios โ€ข iOS 12.1 (simulator)

โ€ข No issues found!

Do you know what may be the issue here?

Upgrade to null safety

Because flutter_svg >=0.21.0-nullsafety.0 depends on xml ^5.0.0 and drawing_animation 0.1.4 depends on xml ^4.1.0, flutter_svg >=0.21.0-nullsafety.0 is incompatible with drawing_animation 0.1.4.

Unhandled Exception: NoSuchMethodError: The getter 'isNotEmpty' was called on null.

Flutter Application Displaying white screen after installing.... same result on emulator and device

main.dart import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; import 'package:testing_tabs/BookingHistory.dart';

void main() {
runApp(
MultiProvider(child: MyApp()),
);
}

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
initialRoute: '/',
routes: {
'/': (context) => BookingHistory(),
},
);
}
}

Logs

ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: NoSuchMethodError: The getter 'isNotEmpty' was called on null.
[ ] E/flutter (20114): Receiver: null
[ ] E/flutter (20114): Tried calling: isNotEmpty
[ ] E/flutter (20114): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
[ ] E/flutter (20114): #1 new Nested (package:nested/nested.dart:71:25)
[ ] E/flutter (20114): #2 new MultiProvider (package:provider/src/provider.dart:121:8)
[ ] E/flutter (20114): #3 main (package:testing_tabs/main.dart:7:10)
[ ] E/flutter (20114): #4 _runMainZoned.. (dart:ui/hooks.dart:140:25)
[ ] E/flutter (20114): #5 _rootRun (dart:async/zone.dart:1354:13)
[ ] E/flutter (20114): #6 _CustomZone.run (dart:async/zone.dart:1258:19)
[ ] E/flutter (20114): #7 _runZoned (dart:async/zone.dart:1788:10)
[ ] E/flutter (20114): #8 runZonedGuarded (dart:async/zone.dart:1776:12)
[ ] E/flutter (20114): #9 _runMainZoned. (dart:ui/hooks.dart:133:5)
[ ] E/flutter (20114): #10 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:283:19)
[ ] E/flutter (20114): #11 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
[ ] E/flutter (20114):

Flutter Doctor

Slashs-MacBook-Pro:testing_tabs slashglobal$ flutter doctor -v
[โœ“] Flutter (Channel stable, 2.0.1, on macOS 11.1 20C69 darwin-x64, locale en-US)
โ€ข Flutter version 2.0.1 at /Users/slashglobal/flutter
โ€ข Framework revision c5a4b4029c (2 weeks ago), 2021-03-04 09:47:48 -0800
โ€ข Engine revision 40441def69
โ€ข Dart version 2.12.0

[โœ“] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
โ€ข Android SDK at /Users/slashglobal/Library/Android/sdk
โ€ข Platform android-30, build-tools 30.0.2
โ€ข Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
โ€ข Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
โ€ข All Android licenses accepted.

[โœ“] Xcode - develop for iOS and macOS
โ€ข Xcode at /Applications/Xcode.app/Contents/Developer
โ€ข Xcode 12.4, Build version 12D4e
โ€ข CocoaPods version 1.10.0

[โœ“] Android Studio (version 4.1)
โ€ข Android Studio at /Applications/Android Studio.app/Contents
โ€ข Flutter plugin can be installed from:
๐Ÿ”จ https://plugins.jetbrains.com/plugin/9212-flutter
โ€ข Dart plugin can be installed from:
๐Ÿ”จ https://plugins.jetbrains.com/plugin/6351-dart
โ€ข Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[โœ“] Connected device (2 available)
โ€ข SM A305F (mobile) โ€ข R58M78MVZNJ โ€ข android-arm64 โ€ข Android 10 (API 29)
โ€ข iPhone 12 Pro Max (mobile) โ€ข F02E3034-BDF8-4BDB-8044-1A715AF853CD โ€ข ios โ€ข com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)

โ€ข No issues found!

Erase animation for SVGs

Hi there
I am using this package and I found it helpful. I liked the way it traces the path and shows the drawing effect. I am facing a problem in doing something similar technically but opposite of this animation i.e. erase animation. I want to show an SVG and then trace the path of SVG to erase it.
Can you help me with this either by providing resources or implementing it in the same package?

Loading SVG via network not possible

At the moment, the library allows loading assets via assets;
We would love to be able to load SVG via web. At the moment; as a workaround we do the following:

Modify drawing_animation.dart:
Add the line

export 'src/parser.dart';

Load the file via network, and parse the content as:

  SvgParser example(filePath) {
     SvgParser parser = SvgParser();
     parser.loadFromString(File(filePath).readAsStringSync());
     return parser;
  }

Then use it as:

AnimatedDrawing.paths(svgParser.getPaths())

While loading file via network might not be a priority, we would like parser.dart to be available to use meanwhile.

Unsupported operation: Only hex color format currently supported. String: url(#a)

E/flutter (28747): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Unsupported operation: Only hex color format currently supported. String:  url(#a)
E/flutter (28747): #0      SvgParser.parseColor
parser.dart:28
E/flutter (28747): #1      SvgParser.loadFromString.<anonymous closure>
parser.dart:91
E/flutter (28747): #2      Iterable.forEach (dart:core/iterable.dart:347:35)
E/flutter (28747): #3      SvgParser.loadFromString
parser.dart:63
E/flutter (28747): #4      SvgParser.loadFromFile
parser.dart:124
E/flutter (28747): <asynchronous suspension>

Throws an exception if the animated svg contains URL in the stroke. The SVG is animated but the package fails.

SVG being cropped

Hello, thank you for the great library.

I'm bumping into a weird situation like this: I'm working on a kanji drawing library. Here is the sample SVG:

<svg xmlns="http://www.w3.org/2000/svg" width="109" height="109" viewBox="0 0 109 109">
<g id="kvg:StrokePaths_09924" style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;">
<g id="kvg:09924" kvg:element="้คค">
	<g id="kvg:09924-g1" kvg:element="้ฃ " kvg:variant="true" kvg:original="้ฃŸ" kvg:position="left" kvg:radical="general">
		<path id="kvg:09924-s1" kvg:type="ใ‡’" d="M29.76,11.14c0.06,0.67,0.27,1.78-0.11,2.68c-2.46,5.9-9.55,17.45-19.59,26.14"/>
		<path id="kvg:09924-s2" kvg:type="ใ‡”/ใ‡" d="M32.27,16.83c4.43,1.83,11.44,7.53,12.54,10.38"/>
		<path id="kvg:09924-s3" kvg:type="ใ‡" d="M22.25,31.66c0.36,0.15,1.02,0.19,1.39,0.15c2.3-0.25,9.87-2.17,12.1-2c0.6,0.05,0.96,0.07,1.27,0.14"/>
		<path id="kvg:09924-s4" kvg:type="ใ‡‘" d="M18.27,39.97c0.39,0.82,0.78,1.75,0.78,2.84c0,1.09-0.13,56.6,0,57.69"/>
		<path id="kvg:09924-s5" kvg:type="ใ‡•" d="M19.19,41.67c2.2-0.14,17.91-2.77,19.92-2.93c1.67-0.14,2.74,1.51,2.61,2.31c-0.26,1.64-2.47,19.28-3.02,22.91"/>
		<path id="kvg:09924-s6" kvg:type="ใ‡a" d="M19.58,52.26c2.97,0,17.36-2.4,20.72-2.4"/>
		<path id="kvg:09924-s7" kvg:type="ใ‡a" d="M19.44,64.08c6.06-0.59,11.81-1.65,19.35-2.15"/>
		<path id="kvg:09924-s8" kvg:type="ใ‡c" d="M19.39,77.1c3.73-0.26,15.96-2.78,19.57-2.6c0.97,0.05,1.56,0.07,2.05,0.15"/>
		<path id="kvg:09924-s9" kvg:type="ใ‡c" d="M19.89,90.92c3.73-0.26,16.46-2.26,20.07-2.08c0.97,0.05,1.56,0.07,2.05,0.15"/>
	</g>
	<g id="kvg:09924-g2" kvg:element="็‚Ž" kvg:position="right">
		<g id="kvg:09924-g3" kvg:element="็ซ" kvg:position="top">
			<path id="kvg:09924-s10" kvg:type="ใ‡”" d="M49.87,23.33c2.71,2.52,6.65,9.67,7.38,12.19"/>
			<path id="kvg:09924-s11" kvg:type="ใ‡’" d="M87,18.53c0.54,0.55,0.14,2.77-0.35,3.62c-0.49,0.85-4.86,5.98-7.3,7.96"/>
			<path id="kvg:09924-s12" kvg:type="ใ‡’" d="M67.28,12.25c0.99,0.42,1.55,2.48,1.49,3.18C66.92,35.86,64.17,45.55,48,54.5"/>
			<path id="kvg:09924-s13" kvg:type="ใ‡" d="M67.76,28.83C74.81,37.69,83.35,46.7,88,50.39c1.46,1.16,1.8,1.03,3,1.33"/>
		</g>
		<g id="kvg:09924-g4" kvg:element="็ซ" kvg:position="bottom">
			<path id="kvg:09924-s14" kvg:type="ใ‡”" d="M49,61.25c4.51,2.47,7.31,8.6,8.54,11.08"/>
			<path id="kvg:09924-s15" kvg:type="ใ‡’" d="M88.71,57.15c0.54,1.33-0.06,2.95-0.68,4.11c-0.62,1.16-4.92,5.51-8,8.21"/>
			<path id="kvg:09924-s16" kvg:type="ใ‡’" d="M68.58,51c0.67,0.75,1.09,2.62,1.06,3.41C68.5,81.25,56.5,91.25,43.18,97.5"/>
			<path id="kvg:09924-s17" kvg:type="ใ‡" d="M69.39,68.71c7.71,10.63,17.06,21.44,22.15,25.87c1.6,1.39,1.97,1.24,3.28,1.59"/>
		</g>
	</g>
</g>
</g>
<g id="kvg:StrokeNumbers_09924" style="font-size:8;fill:#808080">
	<text transform="matrix(1 0 0 1 22.50 10.50)">1</text>
	<text transform="matrix(1 0 0 1 35.50 16.50)">2</text>
	<text transform="matrix(1 0 0 1 27.50 28.50)">3</text>
	<text transform="matrix(1 0 0 1 12.50 48.50)">4</text>
	<text transform="matrix(1 0 0 1 20.50 38.50)">5</text>
	<text transform="matrix(1 0 0 1 23.11 49.50)">6</text>
	<text transform="matrix(1 0 0 1 23.17 60.50)">7</text>
	<text transform="matrix(1 0 0 1 23.13 73.50)">8</text>
	<text transform="matrix(1 0 0 1 23.12 87.50)">9</text>
	<text transform="matrix(1 0 0 1 46.50 20.50)">10</text>
	<text transform="matrix(1 0 0 1 79.50 15.50)">11</text>
	<text transform="matrix(1 0 0 1 56.50 10.50)">12</text>
	<text transform="matrix(1 0 0 1 79.50 38.50)">13</text>
	<text transform="matrix(1 0 0 1 51.25 61.50)">14</text>
	<text transform="matrix(1 0 0 1 78.50 58.58)">15</text>
	<text transform="matrix(1 0 0 1 58.25 53.50)">16</text>
	<text transform="matrix(1 0 0 1 78.50 78.50)">17</text>
</g>
</svg>

It is this character: ้คค

However when I use the lib to draw it, some strokes are cropped at corners like so:

image

Where should I look at? I think it's the problem with canvas size and I would like to extend it a bit more, but no clue still.

Problem with colors

Hi @biocarl!

I tried the example3 but the page with the color example doesn't seem to be working, the lines painting it black. :(

Thanks!

Only hex color format currently supported

Hello,

I'm trying to use these animated icons in my app : https://github.com/basmilius/weather-icons

I'm getting this error :

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Unsupported operation: Only hex color format currently supported. String:  url(#a)
SvgParser.parseColor (package:drawing_animation/src/parser.dart:28:7)
SvgParser.loadFromString.<anonymous closure> (package:drawing_animation/src/parser.dart:91:19)
Iterable.forEach (dart:core/iterable.dart:346:35)
SvgParser.loadFromString (package:drawing_animation/src/parser.dart:63:10)
SvgParser.loadFromFile (package:drawing_animation/src/parser.dart:124:5)
<asynchronous suspension>

callback while rendering a path

Awesome work on the library.

I was wondering if it is possible to add a callback as a Path is rendered.
The onPaint callback is called after a entire path is completed.

I was trying to achieve results similar to this.

Trouble with colors

Hey @biocarl!
Thanks for the library it's awesome.

Im having trouble making the lines of a given color other than black. I tried the example3 but the page with the color example doesn't seem to be working for me.
I have a svg file with colored strokes but it keeps painting it black.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.