李卓原

5.6.0

# 5.6.0
- bug fix: #434
- add w and h on EdgeInsets,Radius,BorderRadius,BoxConstraints
# 5.5.4
- Bug Fix: False sizes when using DevicePreview
... ...
... ... @@ -195,8 +195,12 @@ class _HomePageState extends State<HomePage> {
20.setVerticalSpacing // SizedBox(height: 20 * scaleHeight)
20.horizontalSpace // SizedBox(height: 20 * scaleWidth)
const RPadding.all(8) // Padding.all(8.r) - take advantage of const key word
EdgeInsets.all(10).w //EdgeInsets.all(10.w)
REdgeInsets.all(8) // EdgeInsets.all(8.r)
EdgeInsets.only(left:8,right:8).r // EdgeInsets.only(left:8.r,right:8.r).
BoxConstraints(maxWidth: 100, minHeight: 100).w //BoxConstraints(maxWidth: 100.w, minHeight: 100.w)
Radius.circular(16).w //Radius.circular(16.w)
BorderRadius.all(Radius.circular(16)).w
```
#### Adapt screen size
... ...
... ... @@ -188,9 +188,12 @@ class _HomePageState extends State<HomePage> {
20.setVerticalSpacing // SizedBox(height: 20 * scaleHeight)
20.horizontalSpace // SizedBox(height: 20 * scaleWidth)
const RPadding.all(8) // Padding.all(8.r) - 获取到const的优点
REdgeInsts.all(8) // EdgeInsets.all(8.r)
EdgeInsets.all(10).w //EdgeInsets.all(10.w)
REdgeInsets.all(8) // EdgeInsets.all(8.r)
EdgeInsets.only(left:8,right:8).r // EdgeInsets.only(left:8.r,right:8.r).
BoxConstraints(maxWidth: 100, minHeight: 100).w //BoxConstraints(maxWidth: 100.w, minHeight: 100.w)
Radius.circular(16).w //Radius.circular(16.w)
BorderRadius.all(Radius.circular(16)).w
```
... ...
... ... @@ -54,10 +54,12 @@ class HomePageScaffold extends StatelessWidget {
),
// Without using Extensions
Container(
padding: EdgeInsets.all(ScreenUtil().setWidth(10)),
width: ScreenUtil().setWidth(180),
height: ScreenUtil().setHeight(200),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(16).w),
color: Colors.blue,
),
constraints: BoxConstraints(maxWidth: 100, minHeight: 100).w,
padding: EdgeInsets.all(10.w),
child: Text(
'My design draft width: 180dp\n\n'
'My design draft height: 200dp',
... ...
... ... @@ -60,10 +60,12 @@ class HomePageScaffold extends StatelessWidget {
],
),
Container(
padding: EdgeInsets.all(ScreenUtil().setWidth(10)),
width: 100.r,
height: 100.r,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(16)).w,
color: Colors.green,
),
constraints: BoxConstraints(maxWidth: 100, minHeight: 100).r,
padding: EdgeInsets.all(10).w,
child: Text(
'我是正方形,边长是100',
style: TextStyle(
... ...
... ... @@ -57,12 +57,14 @@ extension EdgeInsetsExtension on EdgeInsets {
right: right.r,
left: left.r,
);
EdgeInsets get w => copyWith(
top: top.w,
bottom: bottom.w,
right: right.w,
left: left.w,
);
EdgeInsets get h => copyWith(
top: top.h,
bottom: bottom.h,
... ... @@ -79,12 +81,14 @@ extension BorderRaduisExtension on BorderRadius {
topLeft: topLeft.r,
topRight: topRight.r,
);
BorderRadius get w => copyWith(
bottomLeft: bottomLeft.w,
bottomRight: bottomRight.w,
topLeft: topLeft.w,
topRight: topRight.w,
);
BorderRadius get h => copyWith(
bottomLeft: bottomLeft.h,
bottomRight: bottomRight.h,
... ... @@ -96,7 +100,9 @@ extension BorderRaduisExtension on BorderRadius {
extension RaduisExtension on Radius {
/// Creates adapt Radius using r [SizeExtension].
Radius get r => Radius.elliptical(x.r, y.r);
Radius get w => Radius.elliptical(x.w, y.w);
Radius get h => Radius.elliptical(x.h, y.h);
}
... ... @@ -116,12 +122,14 @@ extension BoxConstraintsExtension on BoxConstraints {
minHeight: minHeight.h,
minWidth: minWidth.w,
);
BoxConstraints get w => this.copyWith(
maxHeight: maxHeight.w,
maxWidth: maxWidth.w,
minHeight: minHeight.w,
minWidth: minWidth.w,
);
BoxConstraints get h => this.copyWith(
maxHeight: maxHeight.h,
maxWidth: maxWidth.h,
... ...