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
Mounir Bouaiche
2023-06-11 21:02:55 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
480205cabe3517c2c9d3d0e710a68295738ee0fa
480205ca
1 parent
fa79c78f
Add fontSizeResolver to init + helpers
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
lib/src/screenutil_init.dart
lib/src/screenutil_init.dart
View file @
480205c
...
...
@@ -39,6 +39,28 @@ abstract class RebuildFactors {
}
}
abstract
class
FontSizeResolvers
{
static
double
width
(
num
fontSize
,
ScreenUtil
instance
)
{
return
instance
.
setWidth
(
fontSize
);
}
static
double
height
(
num
fontSize
,
ScreenUtil
instance
)
{
return
instance
.
setHeight
(
fontSize
);
}
static
double
raduis
(
num
fontSize
,
ScreenUtil
instance
)
{
return
instance
.
radius
(
fontSize
);
}
static
double
diameter
(
num
fontSize
,
ScreenUtil
instance
)
{
return
instance
.
diameter
(
fontSize
);
}
static
double
diagonal
(
num
fontSize
,
ScreenUtil
instance
)
{
return
instance
.
diagonal
(
fontSize
);
}
}
class
ScreenUtilInit
extends
StatefulWidget
{
/// A helper widget that initializes [ScreenUtil]
const
ScreenUtilInit
({
...
...
@@ -52,6 +74,7 @@ class ScreenUtilInit extends StatefulWidget {
this
.
useInheritedMediaQuery
=
false
,
this
.
ensureScreenSize
,
this
.
responsiveWidgets
,
this
.
fontSizeResolver
=
FontSizeResolvers
.
width
,
})
:
super
(
key:
key
);
final
ScreenUtilInitBuilder
?
builder
;
...
...
@@ -61,6 +84,7 @@ class ScreenUtilInit extends StatefulWidget {
final
bool
useInheritedMediaQuery
;
final
bool
?
ensureScreenSize
;
final
RebuildFactor
rebuildFactor
;
final
FontSizeResolver
fontSizeResolver
;
/// The [Size] of the device in the design draft, in dp
final
Size
designSize
;
...
...
@@ -146,6 +170,7 @@ class _ScreenUtilInitState extends State<ScreenUtilInit>
splitScreenMode:
widget
.
splitScreenMode
,
minTextAdapt:
widget
.
minTextAdapt
,
ensureScreenHasSize:
widget
.
ensureScreenSize
,
fontSizeResolver:
widget
.
fontSizeResolver
,
);
return
widget
.
builder
?.
call
(
context
,
widget
.
child
)
??
widget
.
child
!;
...
...
Please
register
or
login
to post a comment