NishadAvnish

added for split screen by setting min height

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,28 +5,34 @@ 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;
BoxConstraints constraints1 = BoxConstraints(maxHeight: 0.0);
@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (_, BoxConstraints constraints) {
if (constraints.maxHeight > constraints1.maxHeight) {
constraints1 = constraints;
if (splitScreenMode) {
constraints = BoxConstraints(
minHeight: constraints.minHeight,
maxHeight: max(constraints.maxHeight, 700),
minWidth: constraints.minWidth,
maxWidth: constraints.maxWidth);
}
if (constraints1.maxWidth != 0) {
if (constraints.maxWidth != 0) {
final Orientation orientation =
constraints1.maxWidth > constraints1.maxHeight
constraints.maxWidth > constraints.maxHeight
? Orientation.landscape
: Orientation.portrait;
ScreenUtil.init(
constraints1,
constraints,
orientation: orientation,
designSize: designSize,
);
... ...