bessel_tween 0.1.1
bessel_tween #
贝塞尔曲线补间动画,用来实现一个Widget按照贝塞尔曲线路径移动。 可实现多阶贝塞尔曲线
-
安装bessel_tween
修改yaml
dependencies: bessel_tween: ^0.1.0
安装
$ flutter packages get
-
使用bessel_tween
import 'package:flutter/animation.dart'; import 'package:bessel_tween/bessel_tween.dart'; void initState() { // 定义3个控制点,可以更多 pointList = [Offset(0, 0), Offset(250, 20), Offset(300, 300)]; AnimationController controller = AnimationController(duration: Duration(milliseconds: 3000), vsync: this); Animation<Offset> besselAnimation = BesselTween(pointList).animate(controller); controller.addListener(() { setState(() { //改变 Widget 的位置 widgetOffset = besselAnimation.value; }); }); controller.forward(); }
-
运行效果动图
实现效果的代码在example里,debug模式会有点卡顿,在release模式里就会极其丝滑
最后感谢 https://blog.csdn.net/aimeimeits/article/details/72809382 这篇文章的作者。
本package的算法部分来自于上面那篇文章
[0.1.0] - 发布第一个版本
- 可输入一系列的贝塞尔曲线控制点,然后根据时间(0~1)计算出点的坐标
example #
A new Flutter project.
Getting Started #
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
bessel_tween: ^0.1.1
2. Install it
You can install packages from the command line:
with Flutter:
$ flutter pub get
Alternatively, your editor might support flutter pub get
.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import 'package:bessel_tween/bessel_tween.dart';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
10
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100
|
Overall:
Weighted score of the above.
[more]
|
55
|
We analyzed this package on Dec 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.6.1
- pana: 0.12.21
- Flutter: 1.9.1+hotfix.6
Platforms
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
Dependencies
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.1.0 <3.0.0 | ||
flutter | 0.0.0 | ||
Transitive dependencies | |||
collection | 1.14.11 | 1.14.12 | |
meta | 1.1.7 | 1.1.8 | |
sky_engine | 0.0.99 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 | ||
Dev dependencies | |||
flutter_test |