Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
flutter_screenutil
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
李卓原
2022-10-27 16:26:02 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b5517e312d7e5e6d7a4bf7dd7e31c71cf468a119
b5517e31
1 parent
10bd42e4
5.6.0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
8 deletions
CHANGELOG.md
README.md
README_CN.md
example/lib/src/home.dart
example/lib/src_zh/home.dart
lib/src/size_extension.dart
CHANGELOG.md
View file @
b5517e3
# 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
...
...
README.md
View file @
b5517e3
...
...
@@ -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
...
...
README_CN.md
View file @
b5517e3
...
...
@@ -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
```
...
...
example/lib/src/home.dart
View file @
b5517e3
...
...
@@ -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'
,
...
...
example/lib/src_zh/home.dart
View file @
b5517e3
...
...
@@ -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
(
...
...
lib/src/size_extension.dart
View file @
b5517e3
...
...
@@ -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
,
...
...
Please
register
or
login
to post a comment