Skip to content

Commit

Permalink
Merge pull request OpenFlutter#291 from NishadAvnish/support_for_spli…
Browse files Browse the repository at this point in the history
…t_screen

Support for split screen
  • Loading branch information
lizhuoyuan authored Nov 24, 2021
2 parents 4d39385 + 5e0ba89 commit bf88c8a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
7 changes: 3 additions & 4 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/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"
Expand Down
4 changes: 3 additions & 1 deletion example/lib/main_zh.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

Expand Down Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions lib/flutter_screenutil.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ library flutter_screenutil;

import 'dart:math';
import 'dart:ui' as ui;
import 'dart:ui';

import 'package:flutter/material.dart';

Expand Down
17 changes: 14 additions & 3 deletions lib/screenutil_init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,32 @@ 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;

@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
? Orientation.landscape
: Orientation.portrait;
final Orientation orientation =
constraints.maxWidth > constraints.maxHeight
? Orientation.landscape
: Orientation.portrait;
ScreenUtil.init(
constraints,
orientation: orientation,
Expand Down

0 comments on commit bf88c8a

Please sign in to comment.