Encrypted peer-to-peer IM for data security. Own data, own privacy. (Rust+Flutter)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

38 lines
1.3 KiB

import 'package:flutter/material.dart';
enum DisplayType {
desktop,
mobile,
}
const _desktopPortraitBreakpoint = 800.0;
const _desktopLandscapeBreakpoint = 1000.0;
/// Returns the [DisplayType] for the current screen. This app only supports
/// mobile and desktop layouts, and as such we only have one breakpoint.
DisplayType displayTypeOf(BuildContext context) {
final orientation = MediaQuery.of(context).orientation;
final width = MediaQuery.of(context).size.width;
if ((orientation == Orientation.landscape &&
width > _desktopLandscapeBreakpoint) ||
(orientation == Orientation.portrait &&
width > _desktopPortraitBreakpoint)) {
return DisplayType.desktop;
} else {
return DisplayType.mobile;
}
}
/// Returns a boolean if we are in a display of [DisplayType.desktop]. Used to
/// build adaptive and responsive layouts.
bool isDisplayDesktop(BuildContext context) {
return displayTypeOf(context) == DisplayType.desktop;
}
/// Returns a boolean if we are in a display of [DisplayType.desktop] but less
/// than [_desktopLandscapeBreakpoint] width. Used to build adaptive and responsive layouts.
bool isDisplaySmallDesktop(BuildContext context) {
return isDisplayDesktop(context) &&
MediaQuery.of(context).size.width < _desktopLandscapeBreakpoint;
}