-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageBox.dart
49 lines (38 loc) · 1.19 KB
/
ImageBox.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
import 'package:flutter/material.dart';
class ImageBox extends StatelessWidget {
final bool netWork = true;
final String src; // 图片地址
final List<double> borderRadius; // 圆角
final List<double> margin;
final double width;
final double height;
ImageBox({
@required this.src,
this.borderRadius = const [0, 0, 0, 0],
this.width,
this.height,
this.margin = const [0, 0, 0, 0]
});
@override
Widget build (BuildContext context) {
final size =MediaQuery.of(context).size;
return Container(
margin: EdgeInsets.fromLTRB(this.margin[3], this.margin[0], this.margin[1], this.margin[2]),
child: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(this.borderRadius[0]),
topRight: Radius.circular(this.borderRadius[1]),
bottomRight: Radius.circular(this.borderRadius[2]),
bottomLeft: Radius.circular(this.borderRadius[3]),
),
child: FadeInImage.assetNetwork(
placeholder: this.src,
image: this.src,
fit: BoxFit.fill,
width: this.width!=null ? this.width : size.width,
height: this.height
),
),
);
}
}