All Projects → flutter-studio → rebound

flutter-studio / rebound

Licence: Apache-2.0 license
A Flutter library that models spring dynamics and adds real world physics to your app.

Programming Languages

dart
5743 projects
objective c
16641 projects - #2 most used programming language
java
68154 projects - #9 most used programming language

English | 简体中文

Flutter Rebound

pub package

A Flutter library that models spring dynamics and adds real world physics to your app. inspired by Facebook Rebound

图片名称

Usage

To use this plugin, add flutter_rebound as a dependency in your pubspec.yaml file.

Example

// 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<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,
          ),
        ),
      ),
    );
  }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].