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
NishadAvnish
2021-11-14 15:37:21 +0530
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5e0ba891c51eccec5eb6cf4f1e3237bf584e1c97
5e0ba891
1 parent
b1dfa3d7
added for split screen by setting min height
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
7 deletions
example/lib/main_zh.dart
lib/flutter_screenutil.dart
lib/screenutil_init.dart
example/lib/main_zh.dart
View file @
5e0ba89
import
'dart:ui'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
...
...
@@ -50,7 +52,7 @@ class _HomePageState extends State<HomePage> {
Container
(
padding:
EdgeInsets
.
all
(
ScreenUtil
().
setWidth
(
10
)),
width:
180
.
w
,
height:
20
0
.
h
,
height:
12
0
.
h
,
color:
Colors
.
red
,
child:
Text
(
'我的实际宽度:
${180.w}
dp
\n
'
...
...
lib/flutter_screenutil.dart
View file @
5e0ba89
...
...
@@ -7,6 +7,7 @@ library flutter_screenutil;
import
'dart:math'
;
import
'dart:ui'
as
ui
;
import
'dart:ui'
;
import
'package:flutter/material.dart'
;
...
...
lib/screenutil_init.dart
View file @
5e0ba89
...
...
@@ -5,28 +5,34 @@ class ScreenUtilInit extends StatelessWidget {
ScreenUtilInit
({
required
this
.
builder
,
this
.
designSize
=
ScreenUtil
.
defaultSize
,
this
.
splitScreenMode
=
true
,
Key
?
key
,
})
:
super
(
key:
key
);
final
Widget
Function
()
builder
;
final
bool
splitScreenMode
;
/// The [Size] of the device in the design draft, in dp
final
Size
designSize
;
BoxConstraints
constraints1
=
BoxConstraints
(
maxHeight:
0.0
);
@override
Widget
build
(
BuildContext
context
)
{
return
LayoutBuilder
(
builder:
(
_
,
BoxConstraints
constraints
)
{
if
(
constraints
.
maxHeight
>
constraints1
.
maxHeight
)
{
constraints1
=
constraints
;
if
(
splitScreenMode
)
{
constraints
=
BoxConstraints
(
minHeight:
constraints
.
minHeight
,
maxHeight:
max
(
constraints
.
maxHeight
,
700
),
minWidth:
constraints
.
minWidth
,
maxWidth:
constraints
.
maxWidth
);
}
if
(
constraints1
.
maxWidth
!=
0
)
{
if
(
constraints
.
maxWidth
!=
0
)
{
final
Orientation
orientation
=
constraints
1
.
maxWidth
>
constraints1
.
maxHeight
constraints
.
maxWidth
>
constraints
.
maxHeight
?
Orientation
.
landscape
:
Orientation
.
portrait
;
ScreenUtil
.
init
(
constraints
1
,
constraints
,
orientation:
orientation
,
designSize:
designSize
,
);
...
...
Please
register
or
login
to post a comment