svgaplayer_flutter 0.0.4

SVGAPlayer-Flutter #

简体中文

Introduce #

SVGAPlayer is a light-weight animation renderer. You use tools to export svga file from Adobe Animate CC or Adobe After Effects, and then use SVGAPlayer to render animation on mobile application.

SVGAPlayer-Flutter render animation natively via Flutter CustomPainter, brings you a high-performance, low-cost animation experience.

If wonder more information, go to this website.

  • SVGAPlayer-Flutter supports 2.0 format only.

Usage #

Here introduce SVGAPlayer-Flutter usage. Wonder exporting usage? Click here.

Add dependency #

dependencies:
  svgaplayer_flutter: ^0.0.1  #latest version

Locate files #

SVGAPlayer could load svga file from Flutter local assets directory or remote server. Add file to pubspec.yaml by yourself.

Super simple to use #

The simplest way to render an animation is to use SVGASimpleImage component.

class MyWidget extends Widget {

  @override
  Widget build(BuildContext context) {
    return Container(
      child: SVGASimpleImage(
          resUrl: "https://github.com/yyued/SVGA-Samples/blob/master/angel.svga?raw=true"),
    );
  }

}

Animation will run repeatedly. If you wondering a stronger animation controls, use code.

Code to use #

To control an animation rendering, you need to create a SVGAAnimationController instance just like Flutter regular animation. Assign to SVGAImage, load and decode resource using SVGAParser, and then do things as you want with SVGAAnimationController.

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

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
  SVGAAnimationController animationController;

  @override
  void initState() {
    this.animationController = SVGAAnimationController(vsync: this);
    this.loadAnimation();
    super.initState();
  }

  @override
  void dispose() {
    this.animationController.dispose();
    super.dispose();
  }

  void loadAnimation() async {
    final videoItem = await SVGAParser.shared.decodeFromURL(
        "https://github.com/yyued/SVGA-Samples/blob/master/angel.svga?raw=true");
    this.animationController.videoItem = videoItem;
    this
        .animationController
        .repeat() // Try to use .forward() .reverse()
        .whenComplete(() => this.animationController.videoItem = null);
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: SVGAImage(this.animationController),
    );
  }
}

Cache #

We will not manage any caches, you need to use dio or other libraries to handle resource caches.

Use SVGAParser.decodeFromBytes method to decode caching data.

Features #

Here are many feature samples.

0.0.4 (2019-07-01) #

Bug Fixes #
  • Should not draw as groups for bitmap or shape, should draw as a sprite one by one.

0.0.3 (2019-07-01) #

Chores #
  • upgrade to 0.0.3 (3c40d8bf)
  • 0.0.2 released. (7a54b493)
Bug Fixes #

0.0.1 (2019-04-01) #

New Features #
  • Add zh readme. (ed4ceaf8)
  • Add assets to SVGASimpleImage. (34ffe14d)
  • Add decodeFromAssets method to parser. (e2746e62)
  • Add dynamicText dynamicHidden and dynamicDrawer. (0a0f7201)
  • Add SVGASimpleImage. (f6add286)
  • Add static url method to create Widget. (516d356b)
  • Add callbacks. (4fce439d)
  • Add path cache. fix: Miss shape transform. (f8104fb7)
  • Add shape render. (0c75cc32)
  • Add Parser, Player and Bitmap render. (99a1be72)
Other Changes #
  • Update samples and doc. (a5d78c51)
Refactors #
  • use AnimationController base animation. (ac210165)

example/README.md

svgaplayer_flutter_example #

Demonstrates how to use the svgaplayer_flutter plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  svgaplayer_flutter: ^0.0.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:svgaplayer_flutter/svgaplayer_flutter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
74
Health:
Code health derived from static analysis. [more]
93
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
83
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/proto/svga.pb.dart. (-4.89 points)

Analysis of lib/proto/svga.pb.dart reported 10 hints, including:

line 67 col 7: 'pp' is deprecated and shouldn't be used.

line 247 col 7: Name types using UpperCamelCase.

line 274 col 7: Name types using UpperCamelCase.

line 325 col 7: Name types using UpperCamelCase.

line 370 col 7: Name types using UpperCamelCase.

Fix lib/proto/svga.pbenum.dart. (-1.49 points)

Analysis of lib/proto/svga.pbenum.dart reported 3 hints:

line 11 col 7: Name types using UpperCamelCase.

line 33 col 7: Name types using UpperCamelCase.

line 53 col 7: Name types using UpperCamelCase.

Fix lib/player.dart. (-0.50 points)

Analysis of lib/player.dart reported 1 hint:

line 3 col 8: Unused import: 'dart:ui'.

Fix additional 5 files with analysis or formatting issues. (-0.50 points)

Additional issues in the following files:

  • lib/simple_player.dart (1 hint)
  • lib/parser.dart (Run flutter format to format lib/parser.dart.)
  • lib/proto/svga.pbjson.dart (Run flutter format to format lib/proto/svga.pbjson.dart.)
  • lib/proto/svga.pbserver.dart (Run flutter format to format lib/proto/svga.pbserver.dart.)
  • lib/svgaplayer_flutter.dart (Run flutter format to format lib/svgaplayer_flutter.dart.)

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
http ^0.12.0+1 0.12.0+2
path_drawing ^0.4.0 0.4.1
protobuf ^0.13.4 0.13.15
Transitive dependencies
async 2.3.0
charcode 1.1.2
collection 1.14.11
fixnum 0.10.9
http_parser 3.1.3
meta 1.1.6 1.1.7
path 1.6.2
path_parsing 0.1.4
pedantic 1.8.0+1
sky_engine 0.0.99
source_span 1.5.5
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test

Admin