-
Notifications
You must be signed in to change notification settings - Fork 1
/
arc_banner.dart
54 lines (46 loc) · 1.52 KB
/
arc_banner.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
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
class ArcBanner extends StatelessWidget {
List imageSrc;
ArcBanner(this.imageSrc);
@override
Widget build(BuildContext context) {
SwiperPlugin dots = const DotSwiperPaginationBuilder(
size: 5, activeSize: 5, activeColor: Colors.blue);
return ClipPath(
clipper: ArcClipper(),
child: Swiper(
itemBuilder: (BuildContext context, int index) {
return Image.network(
imageSrc[index],
fit: BoxFit.fill,
);
},
itemCount: imageSrc.length,
pagination: SwiperPagination(builder: dots, margin: EdgeInsets.all(15)),
autoplay: true,
),
);
}
}
class ArcClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
var path = Path();
path.lineTo(0.0, size.height);
var firstControlPoint = Offset(size.width / 4, size.height - 8);
var firstPoint = Offset(size.width / 2, size.height - 8);
path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
firstPoint.dx, firstPoint.dy);
var secondControlPoint =
Offset(size.width - (size.width / 4), size.height - 8);
var secondPoint = Offset(size.width, size.height);
path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy,
secondPoint.dx, secondPoint.dy);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}