flutter - 波纹动画 flutter

标签 flutter dart flutter-layout flutter-animation

我想使用 flutter 创建波纹动画。我已经知道涟漪效应,但这不是我想要的,我想要 link 中的东西

最佳答案

输出

enter image description here

  AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(
      vsync: this,
      lowerBound: 0.5,
      duration: Duration(seconds: 3),
    )..repeat();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Title")),
      body: _buildBody(),
    );
  }

  Widget _buildBody() {
    return AnimatedBuilder(
      animation: CurvedAnimation(parent: _controller, curve: Curves.fastOutSlowIn),
      builder: (context, child) {
        return Stack(
          alignment: Alignment.center,
          children: <Widget>[
            _buildContainer(150 * _controller.value),
            _buildContainer(200 * _controller.value),
            _buildContainer(250 * _controller.value),
            _buildContainer(300 * _controller.value),
            _buildContainer(350 * _controller.value),
            Align(child: Icon(Icons.phone_android, size: 44,)),
          ],
        );
      },
    );
  }

  Widget _buildContainer(double radius) {
    return Container(
      width: radius,
      height: radius,
      decoration: BoxDecoration(
        shape: BoxShape.circle,
        color: Colors.blue.withOpacity(1 - _controller.value),
      ),
    );
  }

关于flutter - 波纹动画 flutter ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55611875/

相关文章:

dart - 很难在 flutter 中实现圆角模态底板

dart - Flutter:继承的 Widget 和路由

Flutter:在同一页面中选择过滤器时刷新列表 API

ios - 有没有人在 iOS flutter 上看到过 stripe_payments 的这个编译错误?

Flutter - 如何实现带有命名路由的底部导航栏?

flutter - 如何从RenderBox知道Positioned属性?

flutter - 无法使用静态访问访问实例成员 'pickImage'

android - 如何在 flutter 中对齐卡片 View 中心

ios - 使用 Flutter 插入 sqflite 时出现问题

firebase - 先 flutter 不响应的地方(firestore)