-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy path09. flutter_blur_effect.dart
73 lines (65 loc) · 2.14 KB
/
09. flutter_blur_effect.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
/*
@SUBSCRIBE - [https://www.youtube.com/channel/UCIxJGxcB4pSrIvuv8FyuqUA]
*/
class FlutterBlueEffectNotifier extends ChangeNotifier {
double _blurValue = 0;
double get blurValue => _blurValue;
setBlueValue({required double val}) {
_blurValue = val;
notifyListeners();
}
}
class FlutterBlurEffectView extends StatelessWidget {
const FlutterBlurEffectView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
FlutterBlueEffectNotifier flutterBlueEffectNotifier(
{required bool renderUI}) =>
Provider.of<FlutterBlueEffectNotifier>(context, listen: renderUI);
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.blue,
title: const Text("Flutter Blur Effect")),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 500,
child: Stack(
fit: StackFit.expand,
children: [
SizedBox(
height: 500,
child: ClipRRect(
borderRadius: BorderRadius.circular(25),
child: Image.asset("assets/car.jpeg"))),
SizedBox(
height: 500,
child: BackdropFilter(
child: const SizedBox.shrink(),
filter: ImageFilter.blur(
sigmaX: flutterBlueEffectNotifier(renderUI: false)
.blurValue,
sigmaY: flutterBlueEffectNotifier(renderUI: false)
.blurValue)),
),
],
),
),
const SizedBox(height: 20),
Slider(
min: 0,
max: 10,
value: flutterBlueEffectNotifier(renderUI: true).blurValue,
onChanged: (val) {
flutterBlueEffectNotifier(renderUI: false)
.setBlueValue(val: val);
}),
],
),
);
}
}