李卓原

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.
1 #!/bin/sh 1 #!/bin/sh
2 # This is a generated file; do not edit or check into version control. 2 # This is a generated file; do not edit or check into version control.
3 -export "FLUTTER_ROOT=/Users/lizhuoyuan/Development/flutter"  
4 -export "FLUTTER_APPLICATION_PATH=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example" 3 +export "FLUTTER_ROOT=C:\flutter"
  4 +export "FLUTTER_APPLICATION_PATH=C:\Users\Avnish\Downloads\flutter_screenutil\example"
5 export "COCOAPODS_PARALLEL_CODE_SIGN=true" 5 export "COCOAPODS_PARALLEL_CODE_SIGN=true"
6 -export "FLUTTER_TARGET=lib/main.dart" 6 +export "FLUTTER_TARGET=lib\main.dart"
7 export "FLUTTER_BUILD_DIR=build" 7 export "FLUTTER_BUILD_DIR=build"
8 export "FLUTTER_BUILD_NAME=1.0.0" 8 export "FLUTTER_BUILD_NAME=1.0.0"
9 export "FLUTTER_BUILD_NUMBER=1" 9 export "FLUTTER_BUILD_NUMBER=1"
  1 +import 'dart:ui';
  2 +
1 import 'package:flutter/material.dart'; 3 import 'package:flutter/material.dart';
2 import 'package:flutter_screenutil/flutter_screenutil.dart'; 4 import 'package:flutter_screenutil/flutter_screenutil.dart';
3 5
@@ -7,6 +7,7 @@ library flutter_screenutil; @@ -7,6 +7,7 @@ library flutter_screenutil;
7 7
8 import 'dart:math'; 8 import 'dart:math';
9 import 'dart:ui' as ui; 9 import 'dart:ui' as ui;
  10 +import 'dart:ui';
10 11
11 import 'package:flutter/material.dart'; 12 import 'package:flutter/material.dart';
12 13
@@ -32,12 +32,15 @@ class ScreenUtil { @@ -32,12 +32,15 @@ class ScreenUtil {
32 BoxConstraints constraints, { 32 BoxConstraints constraints, {
33 Orientation orientation = Orientation.portrait, 33 Orientation orientation = Orientation.portrait,
34 Size designSize = defaultSize, 34 Size designSize = defaultSize,
  35 + bool splitScreenMode = true,
35 }) { 36 }) {
36 _instance = ScreenUtil._() 37 _instance = ScreenUtil._()
37 ..uiSize = designSize 38 ..uiSize = designSize
38 .._orientation = orientation 39 .._orientation = orientation
39 .._screenWidth = constraints.maxWidth 40 .._screenWidth = constraints.maxWidth
40 - .._screenHeight = constraints.maxHeight; 41 + .._screenHeight = splitScreenMode
  42 + ? max(constraints.maxHeight, 700)
  43 + : constraints.maxHeight;
41 44
42 var window = WidgetsBinding.instance?.window ?? ui.window; 45 var window = WidgetsBinding.instance?.window ?? ui.window;
43 _instance._pixelRatio = window.devicePixelRatio; 46 _instance._pixelRatio = window.devicePixelRatio;
@@ -5,10 +5,12 @@ class ScreenUtilInit extends StatelessWidget { @@ -5,10 +5,12 @@ class ScreenUtilInit extends StatelessWidget {
5 ScreenUtilInit({ 5 ScreenUtilInit({
6 required this.builder, 6 required this.builder,
7 this.designSize = ScreenUtil.defaultSize, 7 this.designSize = ScreenUtil.defaultSize,
  8 + this.splitScreenMode = true,
8 Key? key, 9 Key? key,
9 }) : super(key: key); 10 }) : super(key: key);
10 11
11 final Widget Function() builder; 12 final Widget Function() builder;
  13 + final bool splitScreenMode;
12 14
13 /// The [Size] of the device in the design draft, in dp 15 /// The [Size] of the device in the design draft, in dp
14 final Size designSize; 16 final Size designSize;
@@ -16,10 +18,19 @@ class ScreenUtilInit extends StatelessWidget { @@ -16,10 +18,19 @@ class ScreenUtilInit extends StatelessWidget {
16 @override 18 @override
17 Widget build(BuildContext context) { 19 Widget build(BuildContext context) {
18 return LayoutBuilder(builder: (_, BoxConstraints constraints) { 20 return LayoutBuilder(builder: (_, BoxConstraints constraints) {
  21 + if (splitScreenMode) {
  22 + constraints = BoxConstraints(
  23 + minHeight: constraints.minHeight,
  24 + maxHeight: max(constraints.maxHeight, 700),
  25 + minWidth: constraints.minWidth,
  26 + maxWidth: constraints.maxWidth);
  27 + }
  28 +
19 if (constraints.maxWidth != 0) { 29 if (constraints.maxWidth != 0) {
20 - final Orientation orientation = constraints.maxWidth > constraints.maxHeight  
21 - ? Orientation.landscape  
22 - : Orientation.portrait; 30 + final Orientation orientation =
  31 + constraints.maxWidth > constraints.maxHeight
  32 + ? Orientation.landscape
  33 + : Orientation.portrait;
23 ScreenUtil.init( 34 ScreenUtil.init(
24 constraints, 35 constraints,
25 orientation: orientation, 36 orientation: orientation,