LiZhuoyuan
Committed by GitHub

Merge pull request #291 from NishadAvnish/support_for_split_screen

Support for split screen
#!/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 "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
... ...
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: 200.h,
height: 120.h,
color: Colors.red,
child: Text(
'我的实际宽度:${180.w}dp \n'
... ...
... ... @@ -7,6 +7,7 @@ library flutter_screenutil;
import 'dart:math';
import 'dart:ui' as ui;
import 'dart:ui';
import 'package:flutter/material.dart';
... ...
... ... @@ -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(
... ...