-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrecord_box_view.dart
More file actions
84 lines (76 loc) · 2.51 KB
/
record_box_view.dart
File metadata and controls
84 lines (76 loc) · 2.51 KB
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
75
76
77
78
79
80
81
82
83
84
import 'package:flutter/material.dart';
import 'package:flutter_custom_carousel/flutter_custom_carousel.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'demo_chrome.dart';
/// Simple, stateless vertical scroller. Mostly just here because it's fun to play with.
///
/// Demonstrates:
/// - a relatively complex [CustomCarousel.effectsBuilder] function using [CustomCarousel.effectsBuilderFromAnimate]
/// - using [CustomCarousel.scrollSpeed] to accelerate the scroll interaction
///
/// Please note: to keep things simple, all demos were built for portrait mode
/// on mobile handsets, without a lot of effort or testing for responsiveness.
class RecordBoxView extends StatelessWidget {
const RecordBoxView({super.key});
@override
Widget build(BuildContext context) {
return DemoChrome(
backgroundColor: const Color(0xFF1F1B2E),
body: SafeArea(
bottom: false,
minimum: const EdgeInsets.only(top: 32),
child: _buildCarousel(),
),
);
}
Widget _buildCarousel() {
List<Widget> items = List.generate(15, (i) => _Card(i));
// See `card_deck_view.dart` for a fully commented example of using
// Animate with CustomCarousel.
return CustomCarousel(
itemCountBefore: 4,
itemCountAfter: 4,
loop: true,
tapToSelect: false,
scrollSpeed: 5,
effectsBuilder: CustomCarousel.effectsBuilderFromAnimate(
effects: EffectList()
.tint(begin: 0.5, color: const Color(0xFF1F1B2E))
.flipV(begin: -0.15, end: 0.5)
.slideY(end: 0.5)
.scaleXY(begin: 0.75, curve: Curves.fastEaseInToSlowEaseOut)
.align(
begin: const Alignment(0, -1),
end: const Alignment(0, 1),
curve: Curves.easeIn,
),
),
children: items,
);
}
}
class _Card extends StatelessWidget {
const _Card(this.index, {Key? key}) : super(key: key);
final int index;
@override
Widget build(BuildContext context) {
return FractionallySizedBox(
widthFactor: 0.7,
child: AspectRatio(
aspectRatio: 1,
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/record_box/album-$index.jpg'),
fit: BoxFit.cover,
),
border: const Border(
top: BorderSide(color: Colors.white38, width: 2),
),
borderRadius: BorderRadius.circular(12),
),
),
),
);
}
}