LiZhuoyuan
Committed by GitHub

Merge pull request #291 from NishadAvnish/support_for_split_screen

Support for split screen
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 "SYMROOT=${SOURCE_ROOT}/../build/ios"  
9 export "FLUTTER_BUILD_NAME=1.0.0" 8 export "FLUTTER_BUILD_NAME=1.0.0"
10 export "FLUTTER_BUILD_NUMBER=1" 9 export "FLUTTER_BUILD_NUMBER=1"
11 export "DART_OBFUSCATION=false" 10 export "DART_OBFUSCATION=false"
  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
@@ -50,7 +52,7 @@ class _HomePageState extends State<HomePage> { @@ -50,7 +52,7 @@ class _HomePageState extends State<HomePage> {
50 Container( 52 Container(
51 padding: EdgeInsets.all(ScreenUtil().setWidth(10)), 53 padding: EdgeInsets.all(ScreenUtil().setWidth(10)),
52 width: 180.w, 54 width: 180.w,
53 - height: 200.h, 55 + height: 120.h,
54 color: Colors.red, 56 color: Colors.red,
55 child: Text( 57 child: Text(
56 '我的实际宽度:${180.w}dp \n' 58 '我的实际宽度:${180.w}dp \n'
@@ -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
@@ -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,8 +18,17 @@ class ScreenUtilInit extends StatelessWidget { @@ -16,8 +18,17 @@ 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 30 + final Orientation orientation =
  31 + constraints.maxWidth > constraints.maxHeight
21 ? Orientation.landscape 32 ? Orientation.landscape
22 : Orientation.portrait; 33 : Orientation.portrait;
23 ScreenUtil.init( 34 ScreenUtil.init(