Skip to content

Commit

Permalink
Add EffectList
Browse files Browse the repository at this point in the history
  • Loading branch information
gskinner committed Nov 22, 2023
1 parent 371b758 commit f447db9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [4.3.0] - 2023-09-21
### Added
- `AlignEffect`
- `AlignEffect` - animated alignment
- `transformHitTests` on `ScaleEffect` and `RotateEffect`
- `EffectList` - build lists of effects with the chained API

### Changed
- fix to properly support `FollowPathEffect.rotate`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Flutter Animate
A performant library that makes it simple to add almost any kind of animated
effect in Flutter.

1. Pre-built effects, like fade, scale, slide, align, flip, blur, shake,
1. Pre-built effects like fade, scale, slide, align, flip, blur, shake,
shimmer, shadows, crossfades, follow path, and color effects (saturation,
color, and tint)
2. Easy custom effects and simplified animated builders
Expand Down
1 change: 1 addition & 0 deletions lib/flutter_animate.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export 'src/animate.dart';
export 'src/animate_list.dart';
export 'src/effect_list.dart';
export 'src/flutter_animate.dart';
export 'src/adapters/adapters.dart';
export 'src/effects/effects.dart';
Expand Down
37 changes: 37 additions & 0 deletions lib/src/effect_list.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'dart:collection';
import '../flutter_animate.dart';

/// Simple helper class to build a list of effects via the chained api.
/// Example:
///
/// ```
/// List<Effect> myEffects = EffectList().fadeIn().scale();
/// // ...
/// Animate(effects: myEffects, child: foo);
/// ```
class EffectList extends ListBase<Effect> with AnimateManager<EffectList> {
final List<Effect> _effects = [];

@override
EffectList addEffect(Effect effect) {
_effects.add(effect);
return this;
}

// concrete implementations required when extending ListBase:
@override
set length(int length) {
_effects.length = length;
}

@override
int get length => _effects.length;

@override
Effect operator [](int index) => _effects[index];

@override
void operator []=(int index, Effect value) {
_effects[index] = value;
}
}

0 comments on commit f447db9

Please sign in to comment.