Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flutter-studio/rebound
A Flutter library that models spring dynamics and adds real world physics to your app.
https://github.com/flutter-studio/rebound
animation flutter rebound spring
Last synced: about 22 hours ago
JSON representation
A Flutter library that models spring dynamics and adds real world physics to your app.
- Host: GitHub
- URL: https://github.com/flutter-studio/rebound
- Owner: flutter-studio
- License: apache-2.0
- Created: 2019-12-05T02:08:08.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-06T10:05:40.000Z (about 5 years ago)
- Last Synced: 2023-08-20T22:04:26.955Z (over 1 year ago)
- Topics: animation, flutter, rebound, spring
- Language: Dart
- Homepage:
- Size: 266 KB
- Stars: 15
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
English | [简体中文](./README_zh-CN.md)
# Flutter Rebound
[![pub package](https://img.shields.io/pub/v/flutter_rebound.svg)](https://pub.dartlang.org/packages/flutter_rebound)
A Flutter library that models spring dynamics and adds real world physics to your app. inspired by Facebook [Rebound](https://github.com/facebook/rebound)
## Usage
To use this plugin, add `flutter_rebound` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/).## Example
``` dart
// Import package
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,
),
),
),
);
}
}
```