Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added sigmaX & sigmaY for more blur customisation #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.0.1"
version: "3.1.0"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -49,14 +49,14 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -94,7 +94,7 @@ packages:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -108,7 +108,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -120,7 +120,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -155,21 +155,14 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.8"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.16.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.5.0"
12 changes: 11 additions & 1 deletion lib/blur.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
library blur;

import 'dart:ui';

import 'package:flutter/material.dart';

///blur it's [child]
///[blur] is the value of blur effect, higher the blur more the blur effect (default value = 5)
///[sigmaX] is the value of sigmaX used in ImageFilter.blur, if provided it will override the blur value (default value = null)
///[sigmaY] is the value of sigmaY used in ImageFilter.blur, if provided it will override the blur value (default value = null)
///[blurColor] is the color of blur effect (default value = Colors.white)
///[borderRadius] is the radius of the child to be blurred
///[colorOpacity] is the opacity of the blurColor (default value = 0.5)
Expand All @@ -20,6 +23,8 @@ class Blur extends StatelessWidget {
this.colorOpacity = 0.5,
this.overlay,
this.alignment = Alignment.center,
this.sigmaX,
this.sigmaY,
}) : super(key: key);

final Widget child;
Expand All @@ -29,6 +34,8 @@ class Blur extends StatelessWidget {
final double colorOpacity;
final Widget? overlay;
final AlignmentGeometry alignment;
final double? sigmaX;
final double? sigmaY;

@override
Widget build(BuildContext context) {
Expand All @@ -39,7 +46,10 @@ class Blur extends StatelessWidget {
child,
Positioned.fill(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: blur, sigmaY: blur),
filter: ImageFilter.blur(
sigmaX: sigmaX ?? blur,
sigmaY: sigmaY ?? blur,
),
child: Container(
decoration: BoxDecoration(
color: blurColor.withOpacity(colorOpacity),
Expand Down
23 changes: 8 additions & 15 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -87,7 +87,7 @@ packages:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -101,7 +101,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -113,7 +113,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -148,21 +148,14 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.8"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.16.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.5.0"