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
李卓原
2020-12-16 20:15:39 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
caa26e615cee069cd6a01223aabc7ca6c09ebaa3
caa26e61
1 parent
51445458
null safety
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
71 deletions
CHANGELOG.md
example/pubspec.yaml
lib/screenutil.dart
lib/screenutil_init.dart
pubspec.yaml
CHANGELOG.md
View file @
caa26e6
<!--
*
@Author: zhuoyuan93@gmail.com
*
@Date: 2018-10-16 19:43:03
*
@LastEditors: zhuoyuan93@gmail.com
*
@LastEditTime: 2020年6月20日 11:20:02
*
@Description: Update log
-->
# 5.0.0-nullsafety.0
-
Migrated flutter_screenutil to non-nullable
# 4.0.0-beta3
-
Optimize the way of initialization
...
...
example/pubspec.yaml
View file @
caa26e6
...
...
@@ -16,54 +16,14 @@ dependencies:
flutter
:
sdk
:
flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons
:
^0.1.2
flutter_screenutil
:
path
:
../
dev_dependencies
:
flutter_test
:
sdk
:
flutter
test
:
^1.15.7
dependency_overrides
:
flutter_screenutil
:
path
:
../
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.
flutter
:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design
:
true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.io/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.io/custom-fonts/#from-packages
...
...
lib/screenutil.dart
View file @
caa26e6
...
...
@@ -8,30 +8,26 @@ import 'dart:ui' as ui;
class
ScreenUtil
{
static
const
Size
defaultSize
=
Size
(
1080
,
1920
);
static
ScreenUtil
_instance
;
static
late
ScreenUtil
_instance
;
/// UI设计中手机尺寸 , px
/// Size of the phone in UI Design , px
Size
uiSize
;
late
Size
uiSize
;
/// 控制字体是否要根据系统的“字体大小”辅助选项来进行缩放。默认值为false。
/// allowFontScaling Specifies whether fonts should scale to respect Text Size accessibility settings. The default is false.
bool
allowFontScaling
;
late
bool
allowFontScaling
;
static
double
_pixelRatio
;
static
double
_textScaleFactor
;
static
double
_screenWidth
;
static
double
_screenHeight
;
static
double
_statusBarHeight
;
static
double
_bottomBarHeight
;
static
late
double
_pixelRatio
;
static
late
double
_textScaleFactor
;
static
late
double
_screenWidth
;
static
late
double
_screenHeight
;
static
late
double
_statusBarHeight
;
static
late
double
_bottomBarHeight
;
ScreenUtil
.
_
();
factory
ScreenUtil
()
{
assert
(
_instance
!=
null
,
'
\n
Ensure to initialize ScreenUtil before accessing it.
\n
Please execute the init method : ScreenUtil.init()'
,
);
return
_instance
;
}
...
...
@@ -40,7 +36,7 @@ class ScreenUtil {
Size
designSize
=
defaultSize
,
bool
allowFontScaling
=
false
,
})
{
_instance
??
=
ScreenUtil
.
_
();
_instance
=
ScreenUtil
.
_
();
_instance
..
uiSize
=
designSize
..
allowFontScaling
=
allowFontScaling
;
...
...
@@ -116,7 +112,7 @@ class ScreenUtil {
///Font size adaptation method
///- [fontSize] The size of the font on the UI design, in px.
///- [allowFontScaling]
double
setSp
(
num
fontSize
,
{
bool
allowFontScalingSelf
})
=>
double
setSp
(
num
fontSize
,
{
bool
?
allowFontScalingSelf
})
=>
allowFontScalingSelf
==
null
?
(
allowFontScaling
?
(
fontSize
*
scaleText
)
...
...
lib/screenutil_init.dart
View file @
caa26e6
...
...
@@ -5,10 +5,10 @@ import 'screenutil.dart';
class
ScreenUtilInit
extends
StatelessWidget
{
/// A helper widget that initializes [ScreenUtil]
ScreenUtilInit
({
@
required
this
.
child
,
required
this
.
child
,
this
.
designSize
=
ScreenUtil
.
defaultSize
,
this
.
allowFontScaling
=
false
,
Key
key
,
Key
?
key
,
})
:
super
(
key:
key
);
final
Widget
child
;
...
...
pubspec.yaml
View file @
caa26e6
name
:
flutter_screenutil
description
:
A flutter plugin for adapting screen and font size.Guaranteed to look good on different models
version
:
4.0.0-beta3
version
:
5.0.0-nullsafety.0
homepage
:
https://github.com/OpenFlutter/flutter_screenutil
environment
:
sdk
:
"
>=2.6.0
<3.0.0"
sdk
:
'
>=2.12.0-29.10.beta
<3.0.0'
dependencies
:
flutter
:
...
...
Please
register
or
login
to post a comment