-
Notifications
You must be signed in to change notification settings - Fork 4
/
_background.dart
74 lines (65 loc) · 1.64 KB
/
_background.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
74
part of 'login_screen.dart';
class _Background extends StatefulWidget {
final Widget child;
const _Background({
Key? key,
required this.child,
}) : super(key: key);
@override
_BackgroundState createState() => _BackgroundState();
}
class _BackgroundState extends State<_Background> {
late final VideoPlayerController _controller;
@override
void initState() {
_controller = VideoPlayerController.asset('assets/videos/login_bg.mp4')
..setVolume(0)
..play()
..setLooping(true)
..initialize();
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final backgroundDecoration = BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/login_bg.png'),
fit: BoxFit.cover,
),
);
final videoSize = _controller.value.size;
return Stack(
alignment: Alignment.center,
children: <Widget>[
Container(
decoration: backgroundDecoration,
),
ClipRect(
child: OverflowBox(
maxWidth: double.infinity,
maxHeight: double.infinity,
alignment: Alignment.center,
child: Container(
decoration: backgroundDecoration,
width: videoSize.width,
height: videoSize.height,
child: VideoPlayer(_controller),
),
),
),
Container(
color: Color(0x80000000),
),
Container(
height: Get.height,
child: widget.child,
),
],
);
}
}