Skip to content

Commit f447db9

Browse files
committed
Add EffectList
1 parent 371b758 commit f447db9

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [4.3.0] - 2023-09-21
88
### Added
9-
- `AlignEffect`
9+
- `AlignEffect` - animated alignment
1010
- `transformHitTests` on `ScaleEffect` and `RotateEffect`
11+
- `EffectList` - build lists of effects with the chained API
1112

1213
### Changed
1314
- fix to properly support `FollowPathEffect.rotate`

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Flutter Animate
88
A performant library that makes it simple to add almost any kind of animated
99
effect in Flutter.
1010

11-
1. Pre-built effects, like fade, scale, slide, align, flip, blur, shake,
11+
1. Pre-built effects like fade, scale, slide, align, flip, blur, shake,
1212
shimmer, shadows, crossfades, follow path, and color effects (saturation,
1313
color, and tint)
1414
2. Easy custom effects and simplified animated builders

lib/flutter_animate.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export 'src/animate.dart';
22
export 'src/animate_list.dart';
3+
export 'src/effect_list.dart';
34
export 'src/flutter_animate.dart';
45
export 'src/adapters/adapters.dart';
56
export 'src/effects/effects.dart';

lib/src/effect_list.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import 'dart:collection';
2+
import '../flutter_animate.dart';
3+
4+
/// Simple helper class to build a list of effects via the chained api.
5+
/// Example:
6+
///
7+
/// ```
8+
/// List<Effect> myEffects = EffectList().fadeIn().scale();
9+
/// // ...
10+
/// Animate(effects: myEffects, child: foo);
11+
/// ```
12+
class EffectList extends ListBase<Effect> with AnimateManager<EffectList> {
13+
final List<Effect> _effects = [];
14+
15+
@override
16+
EffectList addEffect(Effect effect) {
17+
_effects.add(effect);
18+
return this;
19+
}
20+
21+
// concrete implementations required when extending ListBase:
22+
@override
23+
set length(int length) {
24+
_effects.length = length;
25+
}
26+
27+
@override
28+
int get length => _effects.length;
29+
30+
@override
31+
Effect operator [](int index) => _effects[index];
32+
33+
@override
34+
void operator []=(int index, Effect value) {
35+
_effects[index] = value;
36+
}
37+
}

0 commit comments

Comments
 (0)