李卓原

Merge branch 'master' of https://github.com/OpenFlutter/flutter_screenutil

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/lizhuoyuan/Development/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example"
export "FLUTTER_ROOT=C:\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Users\Avnish\Downloads\flutter_screenutil\example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
... ...
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
... ...
... ... @@ -7,6 +7,7 @@ library flutter_screenutil;
import 'dart:math';
import 'dart:ui' as ui;
import 'dart:ui';
import 'package:flutter/material.dart';
... ...
... ... @@ -32,12 +32,15 @@ class ScreenUtil {
BoxConstraints constraints, {
Orientation orientation = Orientation.portrait,
Size designSize = defaultSize,
bool splitScreenMode = true,
}) {
_instance = ScreenUtil._()
..uiSize = designSize
.._orientation = orientation
.._screenWidth = constraints.maxWidth
.._screenHeight = constraints.maxHeight;
.._screenHeight = splitScreenMode
? max(constraints.maxHeight, 700)
: constraints.maxHeight;
var window = WidgetsBinding.instance?.window ?? ui.window;
_instance._pixelRatio = window.devicePixelRatio;
... ...
... ... @@ -5,10 +5,12 @@ 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;
... ... @@ -16,8 +18,17 @@ class ScreenUtilInit extends StatelessWidget {
@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (_, BoxConstraints constraints) {
if (splitScreenMode) {
constraints = BoxConstraints(
minHeight: constraints.minHeight,
maxHeight: max(constraints.maxHeight, 700),
minWidth: constraints.minWidth,
maxWidth: constraints.maxWidth);
}
if (constraints.maxWidth != 0) {
final Orientation orientation = constraints.maxWidth > constraints.maxHeight
final Orientation orientation =
constraints.maxWidth > constraints.maxHeight
? Orientation.landscape
: Orientation.portrait;
ScreenUtil.init(
... ...