7 Star 25 Fork 2

flutter-studio / rebound

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README_zh-CN.md 1.79 KB
一键复制 编辑 原始数据 按行查看 历史
leman(tanfu) 提交于 2019-12-11 17:20 . update README_zh-CN.md.

English | 简体中文

Flutter Rebound

pub package

一个Flutter库,模拟弹簧动力学,并添加现实世界的物理到您的应用程序。

输入图片说明

使用

要使用此插件包,请将flutter_rebound作为依赖项添加到您的pubspec.yaml文件中,详见dependency in your pubspec.yaml file.

示例

// 引入包
import 'package:flutter_rebound/flutter_rebound.dart';
import 'package:flutter/material.dart';

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

  final String title;

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

class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
  SpringSystem system;
  Spring spring;
  double _scale = 1;

  @override
  void initState() {
    super.initState();
    system = SpringSystem(vsync: this);
    spring = system.createSpring(40, 3);
    spring.addUpdateListener((spring) {
      double value = spring.currentValue;
      _scale = 1 - value * 0.5;
      setState(() {});
    });
    spring.endValue = 1;
  }

  @override
  void dispose() {
    system.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Transform.scale(
          scale: _scale,
          child: Container(
            width: 200,
            height: 200,
            color: Colors.red,
          ),
        ),
      ),
    );
  }
}
Dart
1
https://gitee.com/flutter-studio/rebound.git
git@gitee.com:flutter-studio/rebound.git
flutter-studio
rebound
rebound
master

搜索帮助