Skip to content

Commit

Permalink
Documentation improvements
Browse files Browse the repository at this point in the history
Primarily to effect extensions
  • Loading branch information
gskinner committed Jan 26, 2024
1 parent 271bab7 commit a118326
Show file tree
Hide file tree
Showing 26 changed files with 132 additions and 76 deletions.
4 changes: 3 additions & 1 deletion lib/src/effects/align_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ class AlignEffect extends Effect<Alignment> {
}
}

/// Adds [AlignEffect] related extensions to [AnimateManager].
extension AlignEffectExtensions<T extends AnimateManager<T>> on T {
/// Adds a [align] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds an [AlignEffect] that animates the target between the specified
/// [begin] and [end] alignments (via [Align]).
T align({
Duration? delay,
Duration? duration,
Expand Down
20 changes: 11 additions & 9 deletions lib/src/effects/blur_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:flutter/widgets.dart';

import '../../flutter_animate.dart';

/// An effect that animates a blur on the target (via [ImageFiltered])
/// between the specified [begin] and [end] blur radiuses.
/// An effect that animates a blur on the target between the
/// specified [begin] and [end] blur radiuses (via [ImageFiltered]).
/// Defaults to `begin=0, end=4`.
@immutable
class BlurEffect extends Effect<Offset> {
Expand Down Expand Up @@ -61,8 +61,10 @@ class BlurEffect extends Effect<Offset> {
}
}

/// Adds [BlurEffect] related extensions to [AnimateManager].
extension BlurEffectExtensions<T extends AnimateManager<T>> on T {
/// Adds a [blur] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds a [BlurEffect] that animates a blur on the target between
/// the specified [begin] and [end] blur radiuses (via [ImageFiltered]).
T blur({
Duration? delay,
Duration? duration,
Expand All @@ -78,8 +80,8 @@ extension BlurEffectExtensions<T extends AnimateManager<T>> on T {
end: end,
));

/// Adds a [blurX] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// This blurs only on the x-axis according to the `double` begin/end values.
/// Adds a [BlurEffect] that animates a horizontal blur on the target between
/// the specified [begin] and [end] blur radiuses (via [ImageFiltered]).
T blurX({
Duration? delay,
Duration? duration,
Expand All @@ -98,8 +100,8 @@ extension BlurEffectExtensions<T extends AnimateManager<T>> on T {
));
}

/// Adds a [blurY] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// This blurs only on the y-axis according to the `double` begin/end values.
/// Adds a [BlurEffect] that animates a vertical blur on the target between
/// the specified [begin] and [end] blur radiuses (via [ImageFiltered]).
T blurY({
Duration? delay,
Duration? duration,
Expand All @@ -118,8 +120,8 @@ extension BlurEffectExtensions<T extends AnimateManager<T>> on T {
));
}

/// Adds a [blurXY] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// This blurs uniformly according to the `double` begin/end values.
/// Adds a [BlurEffect] that animates a uniform blur on the target between
/// the specified [begin] and [end] blur radiuses (via [ImageFiltered]).
T blurXY({
Duration? delay,
Duration? duration,
Expand Down
4 changes: 3 additions & 1 deletion lib/src/effects/box_shadow_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ class BoxShadowEffect extends Effect<BoxShadow> {
}
}

/// Adds [BoxShadowEffect] related extensions to [AnimateManager].
extension BoxShadowEffectExtensions<T extends AnimateManager<T>> on T {
/// Adds a [boxShadow] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds a [BoxShadowEffect] which animates a [BoxShadow] between
/// [begin] and [end] (via [DecoratedBox]).
T boxShadow({
Duration? delay,
Duration? duration,
Expand Down
4 changes: 3 additions & 1 deletion lib/src/effects/callback_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ class CallbackEffect extends Effect<void> {
}
}

/// Adds [CallbackEffect] related extensions to [AnimateManager].
extension CallbackEffectExtensions<T extends AnimateManager<T>> on T {
/// Adds a [callback] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds a [CallbackEffect] that calls a [callback] function at a particular point in the animation.
/// It includes a boolean value indicating if the animation is playing in reverse.
T callback({
Duration? delay,
Duration? duration,
Expand Down
7 changes: 5 additions & 2 deletions lib/src/effects/color_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/widgets.dart';
import '../../flutter_animate.dart';

/// An effect that animates a [Color] between [begin] and [end], composited with
/// the target using [blendMode] (via [ColorFiltered]). A color value of `null` for
/// the target using [blendMode] (via [ColorFiltered]). A color value of `null`
/// will be interpreted as a fully transparent version of the other color.
/// Defaults to `begin=null, end=Color(0x800099FF)`.
///
Expand Down Expand Up @@ -63,8 +63,11 @@ class ColorEffect extends Effect<Color?> {
}
}

/// Adds [ColorEffect] related extensions to [AnimateManager].
extension ColorEffectExtension<T extends AnimateManager<T>> on T {
/// Adds a [color] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds a [ColorEffect] that animates a [Color] between [begin] and [end], composited with
/// the target using [blendMode] (via [ColorFiltered]). A color value of `null`
/// will be interpreted as a fully transparent version of the other color.
T color({
Duration? delay,
Duration? duration,
Expand Down
4 changes: 3 additions & 1 deletion lib/src/effects/crossfade_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ class CrossfadeEffect extends Effect<double> {
}
}

/// Adds [CrossfadeEffect] related extensions to [AnimateManager].
extension CrossfadeEffectExtensions<T extends AnimateManager<T>> on T {
/// Adds a [crossfade] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds a [CrossfadeEffect] that crossfades the incoming child (including preceeding effects)
/// with a new widget (via [Stack] and [FadeTransition]).
T crossfade({
Duration? delay,
Duration? duration,
Expand Down
5 changes: 4 additions & 1 deletion lib/src/effects/custom_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ class CustomEffect extends Effect<double> {
}
}

/// Adds [CustomEffect] related extensions to [AnimateManager].
extension CustomEffectExtensions<T extends AnimateManager<T>> on T {
/// Adds a [custom] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds a [CustomEffect] that animates effects via a [builder] method that
/// accepts a [BuildContext], target child, and calculated animation value
/// between [begin] and [end].
T custom({
required CustomEffectBuilder builder,
Duration? delay,
Expand Down
4 changes: 3 additions & 1 deletion lib/src/effects/effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ class Effect<T> {
}
}

/// Adds [Effect] related extensions to [AnimateManager].
extension EffectExtensions<T extends AnimateManager<T>> on T {
/// Adds an [effect] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds an [Effect] which has no visual effect. Occasionally useful for
/// setting inheritable `delay`, `duration`, and `curve` values.
T effect({
Duration? delay,
Duration? duration,
Expand Down
4 changes: 3 additions & 1 deletion lib/src/effects/elevation_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ class ElevationEffect extends Effect<double> {
}
}

/// Adds [ElevationEffect] related extensions to [AnimateManager].
extension ElevationEffectExtensions<T extends AnimateManager<T>> on T {
/// Adds an [elevation] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds an [ElevationEffect] that animates a Material elevation shadow between [begin] and [end] (via [PhysicalModel]).
/// You can also specify a shadow [color] and [borderRadius] to add rounded corners.
T elevation({
Duration? delay,
Duration? duration,
Expand Down
14 changes: 8 additions & 6 deletions lib/src/effects/fade_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/widgets.dart';

import '../../flutter_animate.dart';

/// An effect that animates the opacity of the target between the specified
/// Animates the opacity of the target between the specified
/// [begin] and [end] values (via [FadeTransition]).
/// It defaults to `begin=0, end=1`.
@immutable
Expand Down Expand Up @@ -35,8 +35,10 @@ class FadeEffect extends Effect<double> {
}
}

/// Adds [FadeEffect] related extensions to [AnimateManager].
extension FadeEffectExtensions<T extends AnimateManager<T>> on T {
/// Adds a [fade] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds a [FadeEffect] that animates the opacity of the target between the
/// specified [begin] and [end] values (via [FadeTransition]).
T fade({
Duration? delay,
Duration? duration,
Expand All @@ -52,8 +54,8 @@ extension FadeEffectExtensions<T extends AnimateManager<T>> on T {
end: end,
));

/// Adds a [fadeIn] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// This is identical to the [fade] extension, except it always uses `end=1.0`.
/// Adds a [FadeEffect] that animates the opacity of the target between the
/// specified [begin] value and `1.0` (via [FadeTransition]).
T fadeIn({
Duration? delay,
Duration? duration,
Expand All @@ -68,8 +70,8 @@ extension FadeEffectExtensions<T extends AnimateManager<T>> on T {
end: 1.0,
));

/// Adds a [fadeOut] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// This is identical to the [fade] extension, except it always uses `end=0.0`.
/// Adds a [FadeEffect] that animates the opacity of the target between `0.0`
/// and the specified [end] value (via [FadeTransition]).
T fadeOut({
Duration? delay,
Duration? duration,
Expand Down
20 changes: 13 additions & 7 deletions lib/src/effects/flip_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import 'package:flutter/widgets.dart';

import '../../flutter_animate.dart';

/// An effect that animates a 2.5D card flip rotation effect (via a matrix [Transform]).
/// An effect that animates a 2.5D card flip rotation effect (via [Transform]).
/// The effect can be horizontal or vertical.
///
/// The [begin] and [end] values specify the number of "flips" (ie. half turns,
/// 180deg or Pi radians) from nominal. For example, `0.5` would be a 90 degree
/// 180° or 𝝅 radians) from nominal. For example, `0.5` would be a 90 degree
/// rotation (half a "flip").
/// It defaults to `begin=-0.5, end=0`.
///
Expand Down Expand Up @@ -91,8 +91,12 @@ class FlipEffect extends Effect<double> {
}
}

/// Adds [FlipEffect] related extensions to [AnimateManager].
extension FlipEffectExtensions<T extends AnimateManager<T>> on T {
/// Adds a [flip] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds a [FlipEffect] that animates a 2.5D card flip rotation effect (via [Transform]).
/// The effect can be horizontal or vertical.
/// The [begin] and [end] values specify the number of "flips" (ie. half turns,
/// 180° or 𝝅 radians) from nominal.
T flip({
Duration? delay,
Duration? duration,
Expand All @@ -114,8 +118,9 @@ extension FlipEffectExtensions<T extends AnimateManager<T>> on T {
direction: direction,
));

/// Adds a [flipH] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// This is identical to the [flip] extension, except it always uses `direction = Axis.horizontal`.
/// Adds a [FlipEffect] that animates a horizontal 2.5D card flip rotation effect (via [Transform]).
/// The [begin] and [end] values specify the number of "flips" (ie. half turns,
/// 180° or 𝝅 radians) from nominal.
T flipH({
Duration? delay,
Duration? duration,
Expand All @@ -136,8 +141,9 @@ extension FlipEffectExtensions<T extends AnimateManager<T>> on T {
direction: Axis.horizontal,
));

/// Adds a [flipV] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// This is identical to the [flip] extension, except it always uses `direction = Axis.vertical`.
/// Adds a [FlipEffect] that animates a vertical 2.5D card flip rotation effect (via [Transform]).
/// The [begin] and [end] values specify the number of "flips" (ie. half turns,
/// 180° or 𝝅 radians) from nominal.
T flipV({
Duration? delay,
Duration? duration,
Expand Down
4 changes: 3 additions & 1 deletion lib/src/effects/follow_path_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ class FollowPathEffect extends Effect<double> {
}
}

/// Adds [FollowPathEffect] related extensions to [AnimateManager].
extension FollowPathEffectExtensions<T extends AnimateManager<T>> on T {
/// Adds a [path] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds a [FollowPathEffect] that moves the target following the specified [path] (via [Transform]).
/// The path coordinates are relative to the target's nominal position.
T followPath({
Duration? delay,
Duration? duration,
Expand Down
4 changes: 3 additions & 1 deletion lib/src/effects/listen_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ class ListenEffect extends Effect<double> {
}
}

/// Adds [ListenEffect] related extensions to [AnimateManager].
extension ListenEffectExtensions<T extends AnimateManager<T>> on T {
/// Adds a [listen] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds a [ListenEffect] that calls a [callback] function with its current animation value
/// between [begin] and [end].
T listen({
Duration? delay,
Duration? duration,
Expand Down
14 changes: 8 additions & 6 deletions lib/src/effects/move_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/widgets.dart';
import '../../flutter_animate.dart';

/// An effect that moves the target between the specified [begin] and [end]
/// offsets (via [Transform.translate])
/// offsets (via [Transform.translate]).
/// Defaults to `begin=Offset(0, -16), end=Offset.zero`.
/// [transformHitTests] is simply passed on to [Transform.translate].
///
Expand Down Expand Up @@ -53,8 +53,10 @@ class MoveEffect extends Effect<Offset> {
}
}

/// Adds [MoveEffect] related extensions to [AnimateManager].
extension MoveEffectExtensions<T extends AnimateManager<T>> on T {
/// Adds a [move] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds a [MoveEffect] that moves the target between the specified [begin] and [end]
/// offsets (via [Transform.translate]).
T move({
Duration? delay,
Duration? duration,
Expand All @@ -72,8 +74,8 @@ extension MoveEffectExtensions<T extends AnimateManager<T>> on T {
transformHitTests: transformHitTests,
));

/// Adds a [moveX] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// This moves only on the x-axis according to the `double` begin/end values.
/// Adds a [MoveEffect] that moves the target horizontally between the specified [begin] and [end]
/// pixel amounts (via [Transform.translate]).
T moveX({
Duration? delay,
Duration? duration,
Expand All @@ -94,8 +96,8 @@ extension MoveEffectExtensions<T extends AnimateManager<T>> on T {
));
}

/// Adds a [moveY] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// This moves only on the y-axis according to the `double` begin/end values.
/// Adds a [MoveEffect] that moves the target vertically between the specified [begin] and [end]
/// pixel amounts (via [Transform.translate]).
T moveY({
Duration? delay,
Duration? duration,
Expand Down
6 changes: 4 additions & 2 deletions lib/src/effects/rotate_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter/widgets.dart';
import '../../flutter_animate.dart';

/// Effect that rotates the target between [begin] and [end] (via [RotationTransition]).
/// Values are specified in "turns", so a `begin=0.25, end=2.25` would start with the child
/// Values are specified in "turns" (360° or 2𝝅 radians), so a `begin=0.25, end=2.25` would start with the child
/// rotated a quarter turn clockwise (90 degrees), and rotate two full turns (ending at 810 degrees).
/// Defaults to `begin=-1.0, end=0`.
///
Expand Down Expand Up @@ -57,8 +57,10 @@ class RotateEffect extends Effect<double> {
}
}

/// Adds [RotateEffect] related extensions to [AnimateManager].
extension RotateEffectExtensions<T extends AnimateManager<T>> on T {
/// Adds a [rotate] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds a [RotateEffect] that rotates the target between [begin] and [end] (via [RotationTransition]).
/// Values are specified in "turns" (360° or 2𝝅 radians).
T rotate({
Duration? delay,
Duration? duration,
Expand Down
10 changes: 7 additions & 3 deletions lib/src/effects/saturate_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ class SaturateEffect extends Effect<double> {
}
}

/// Adds [SaturateEffect] related extensions to [AnimateManager].
extension SaturateEffectExtensions<T extends AnimateManager<T>> on T {
/// Adds a [saturate] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// Adds a [SaturateEffect] that animates the color saturation of the target.
/// Defaults to a begin value of `0` (fully desaturated / grayscale) and
/// an end value of `1` (normal saturation).
T saturate({
Duration? delay,
Duration? duration,
Expand All @@ -77,8 +80,9 @@ extension SaturateEffectExtensions<T extends AnimateManager<T>> on T {
end: end,
));

/// Adds a [desaturate] extension to [AnimateManager] ([Animate] and [AnimateList]).
/// This is identical to the [saturate] extension, except it defaults to `begin=1, end=0`.
/// Adds a [SaturateEffect] that animates the color saturation of the target.
/// Defaults to a begin value of `1` (normal saturation) and
/// an end value of `0` (fully desaturated / grayscale).
T desaturate({
Duration? delay,
Duration? duration,
Expand Down
Loading

0 comments on commit a118326

Please sign in to comment.