gif_ani 0.0.2
gif_ani: ^0.0.2 copied to clipboard

a flutter plugin to control gif animation.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin{
  GifController _animationCtrl;
  @override
  void initState() {
    super.initState();
    _animationCtrl = new GifController(vsync: this,duration: new Duration(milliseconds: 1200),frameCount: 35);
  }
  @override
  void dispose() {
    _animationCtrl.dispose();
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new Center(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new RaisedButton.icon(
              icon: new Icon(Icons.satellite),
              label: new Text("开始动画"),
              onPressed: (){
                _animationCtrl.runAni();
              },
            ),
            new RaisedButton.icon(
              icon: new Icon(Icons.satellite),
              label: new Text("指定帧"),
              onPressed: (){
                _animationCtrl.setFrame(10);
              },
            ),
            new RaisedButton.icon(
              icon: new Icon(Icons.satellite),
              label: new Text("循环动画"),
              onPressed: (){
                _animationCtrl.repeat();
              },
            ),
            _buildGif(),
          ],
        ),
      ),
    );
  }

  Widget _buildGif(){
    Widget ret = new GifAnimation(
      image: new AssetImage("like_anim.gif"),
      controller: _animationCtrl,
    );
    return ret;
  }
}
7
likes
60
pub points
69%
popularity

a flutter plugin to control gif animation.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

1451784145@qq.com

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on gif_ani