Skip to content

Commit

Permalink
🔧 add modulate extension to ColorFilter effect and rename effect_anim…
Browse files Browse the repository at this point in the history
…ation_value.dart to effect_query.dart
  • Loading branch information
SaadArdati committed Jan 12, 2024
1 parent a3b960c commit bf27796
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/hyper_effects.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export 'src/effects/effects.dart';
export 'src/extensions.dart';
export 'src/scroll_phase.dart';
export 'src/scroll_transition.dart';
export 'src/effect_animation_value.dart';
export 'src/effect_query.dart';
export 'src/pointer_transition.dart';
export 'src/apple_curves.dart';
export 'src/post_frame_widget.dart';
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/widgets.dart';

import 'pointer_transition.dart';

/// An inherited widget that provides the animation value to it's descendants.
Expand Down Expand Up @@ -51,7 +52,9 @@ class EffectQuery extends InheritedWidget {

/// Returns the [EffectQuery] from the given [context].
static EffectQuery of(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType<EffectQuery>()!;
final EffectQuery? result = maybeOf(context);
assert(result != null, 'No EffectQuery found in context.');
return result!;
}

/// Returns the [EffectQuery] from the given [context].
Expand Down
2 changes: 1 addition & 1 deletion lib/src/effect_widget.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/widgets.dart';

import 'effect_animation_value.dart';
import 'effect_query.dart';
import 'effects/effect.dart';

/// A widget that applies given [Effect] to a [Widget]. This widget is hardly
Expand Down
17 changes: 17 additions & 0 deletions lib/src/effects/color_filter_effect.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import 'dart:ui';

import 'package:flutter/material.dart';

import '../../hyper_effects.dart';

/// Provides a extension method to apply an [ColorFilterEffect] to a [Widget].
extension ColorFilterEffectExtension on Widget {
/// Applies an [ColorFilterEffect] to a [Widget].
Widget modulate({
Color? color,
BlendMode mode = BlendMode.overlay,
List<double>? matrix,
Color? colorFrom,
List<double>? fromMatrix,
}) =>
this.color(
color: color,
mode: mode,
matrix: matrix,
colorFrom: colorFrom,
fromMatrix: fromMatrix,
);

/// Applies an [ColorFilterEffect] to a [Widget].
Widget color({
Color? color,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/pointer_transition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/widgets.dart';
import 'post_frame_widget.dart';

import 'apple_curves.dart';
import 'effect_animation_value.dart';
import 'effect_query.dart';

/// Represents the pointer event for [PointerTransition].
class PointerTransitionEvent {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/scroll_transition.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/widgets.dart';

import 'effect_animation_value.dart';
import 'effect_query.dart';
import 'extensions.dart';
import 'post_frame_widget.dart';
import 'scroll_phase.dart';
Expand Down

0 comments on commit bf27796

Please sign in to comment.