首页 > 解决方案 > 水平翻转动画 ImageWidget Flutter

问题描述

我想为 CircularAvatar 小部件做水平翻转动画.. 像下面的动画在此处输入图像描述 这样我想翻转 circularAvartar

我试过了

AnimationController _controller;

    AnimatedBuilder(
          animation: _controller,
          builder: (context, child){
            return Transform(
              transform: Matrix4.rotationY((1 - _controller.value ) * pi / 2),
            child: CircleAvatar(
            radius: PROFILE_PIC_RADIUS,
            backgroundImage: AssetImage(url),
           // backgroundColor: Colors.transparent,
            ),
            );
          }
        ),

_controller.forward();
_controller.reverse();

但它不像下面的动画那样工作,我想要像水平方向翻转硬币这样的动画..请给出任何解决方案

标签: flutterflutter-layoutflutter-animation

解决方案


您可以使用库flip_card

将此添加到 pubspec.yaml :

dependencies:
  flip_card: ^0.4.4

然后运行

flutter packages get

要使用:

import 'package:flip_card/flip_card.dart';

FlipCard(
  direction: FlipDirection.HORIZONTAL, // default
  front: Container(
        child: Text('Front'),
    ),
    back: Container(
        child: Text('Back'),
    ),
);

推荐阅读