NiceResponsiveInfo.fromConstraints constructor

NiceResponsiveInfo.fromConstraints(
  1. BuildContext context,
  2. BoxConstraints constraints
)

Create from BoxConstraints

Implementation

factory NiceResponsiveInfo.fromConstraints(
  BuildContext context,
  BoxConstraints constraints,
) {
  final mediaQuery = MediaQuery.of(context);
  final width = constraints.maxWidth;
  final height = constraints.maxHeight;

  return NiceResponsiveInfo(
    screenWidth: width,
    screenHeight: height,
    breakpoint: NiceBreakpoints.fromWidth(width),
    formFactor: NiceBreakpoints.formFactorFromWidth(width),
    orientation: width > height ? Orientation.landscape : Orientation.portrait,
    pixelRatio: mediaQuery.devicePixelRatio,
    textScaleFactor: mediaQuery.textScaleFactor,
  );
}