# rebound **Repository Path**: flutter-studio/rebound ## Basic Information - **Project Name**: rebound - **Description**: 一个Flutter库,模拟弹簧动力学,并添加现实世界的物理动画到您的应用程序。 - **Primary Language**: Dart - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://github.com/flutter-studio/rebound - **GVP Project**: No ## Statistics - **Stars**: 25 - **Forks**: 2 - **Created**: 2019-12-05 - **Last Updated**: 2021-09-18 ## Categories & Tags **Categories**: android-modules **Tags**: None ## README [English](./README.md) | 简体中文 # Flutter Rebound [![pub package](https://img.shields.io/pub/v/flutter_rebound.svg)](https://pub.dartlang.org/packages/flutter_rebound) 一个Flutter库,模拟弹簧动力学,并添加现实世界的物理到您的应用程序。 ![输入图片说明](https://images.gitee.com/uploads/images/2019/1211/171935_4eca7cf0_1183378.gif "SVID_20191205_120702_1.gif") ## 使用 要使用此插件包,请将`flutter_rebound`作为依赖项添加到您的`pubspec.yaml`文件中,详见[dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). ## 示例 ``` dart // 引入包 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 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, ), ), ), ); } } ```